You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
//多重背包问题,每件物品的数量是有限制的,不是无穷,也不是只有1个。
|
|
|
|
|
// 状态表示 集合,属性
|
|
|
|
|
// 状态计算
|
|
|
|
|
|
|
|
|
|
const int N = 110;
|
|
|
|
|
|
|
|
|
|
int n, m;
|
|
|
|
|
int v[N], w[N], s[N];
|
|
|
|
|
int f[N];
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
cin >> n >> m;
|
|
|
|
|
for (int i = 1; i <= n; i++) cin >> v[i] >> w[i] >> s[i];
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= n; i++)
|
|
|
|
|
for (int j = m; j >= 0; j--)
|
|
|
|
|
for (int k = 0; k <= s[i] && k * v[i] <= j; k++) //穷举所有可能性,尝试拿到最大的合理值
|
|
|
|
|
f[j] = max(f[j], f[j - v[i] * k] + w[i] * k);
|
|
|
|
|
|
|
|
|
|
cout << f[m] << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|