\ C++代码
include[HTML_REMOVED]
using namespace std;
const int MX = 1100;
int v[ MX ], w[MX], dp[MX][MX];
int main(){
int N, V;
cin >> N >> V;
for(int i = 1; i <= N; i) cin >> v[i] >> w[i];
for(int i = 1; i <= N; i){
for(int j = 1; j <= V; ++j){
if(j >= v[i]) dp[i][j] = max(dp[i-1][j], dp[i-1][j - v[i]] + w[i]);
else dp[i][j] = dp[i-1][j];
}
}
cout << dp[N][V] << endl;
return 0;
}