题解
水水更健康~
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 5000 + 10;
int dp[maxn];
int n, m;
int main()
{
cin >> n >> m;
int w, v;
for(int i = 0; i < n; ++i)
{
cin >> w >> v;
for(int j = m; j >= w; --j){
dp[j] = max(dp[j], dp[j - w] + v);
}
}
cout << dp[m] << endl;
return 0;
}