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.
20 lines
533 B
20 lines
533 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
const int N = 110;
|
|
int n, m;
|
|
|
|
int f[N][N];
|
|
int main() {
|
|
cin >> n >> m;
|
|
|
|
for (int i = 1; i <= n; i++) { // 讨论每个物品
|
|
int w, v, s;
|
|
cin >> v >> w >> s;
|
|
for (int j = 0; j <= m; j++) // 讨论每个剩余的体积
|
|
for (int k = 0; k <= s && v * k <= j; k++) // 讨论加入的个数
|
|
f[i][j] = max(f[i][j], f[i - 1][j - k * v] + w * k);
|
|
}
|
|
printf("%d\n", f[n][m]);
|
|
return 0;
|
|
}
|