完全背包问题
f(i,j) = max(f(i-1,j),f(i,j-v)+w)
#include<iostream>
using namespace std;
const int N = 1010;
int n, m;
int dp[N][N], v[N], w[N];
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i ++ ){
int v, w;
cin >> v >> w;
for(int j = 0; j <= m; j ++ ){
dp[i][j] = dp[i - 1][j];
if(j >= v)
dp[i][j] = max(dp[i][j], dp[i][j - v] + w);
}
}
cout << dp[n][m] << endl;
}