样例输入
5 1000
80 20 4
40 50 9
30 50 7
40 30 6
20 20 1
样例输出
1040
#include <iostream>
using namespace std;
int w[510], c[510], s[510],dp[6010];
int main() {
int m, n;
cin >> m >> n;
for (int i = 1;i <= m;i++) {
cin >> w[i] >> c[i]>>s[i];
}
for (int i = 1;i <= m;i++)
for (int j = n;j >= 1;j--)
for (int k = 0;k <= s[i]&&j>=k*w[i];k++)
//从01的状态转换方程式,去增加第i个物品拿k个循环
dp[j] = max(dp[j], dp[j - k * w[i]] + k * c[i]);
cout << dp[n];
return 0;
}