$$\color{red}{算法}\color{blue}{基础课}\color{purple}{笔记and题解}\color{green}{汇总}$$
直接暴力拆分变成01背包~
#include <bits/stdc++.h>
using namespace std;
int c[110], w[110], s[110], dp[1010], n, m;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1;i <= n; i++) scanf("%d%d%d", &c[i], &w[i], &s[i]);
for (int i = 1;i <= n; i++)
for (int x = 1;x <= s[i]; x++)
for (int j = m; j >= c[i]; j--)
dp[j] = max(dp[j], dp[j - c[i]] + w[i]);
printf ("%d\n", dp[m]);
return 0;
}
WC!
tql