0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

1269. 【例9.13】庆功会

http://ybt.ssoier.cn:8088/statusx.php?runidx=15610513
This commit is contained in:
Baoshuo Ren 2022-04-04 21:19:24 +08:00
parent 455f0aa2ca
commit fa1c5990d3
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

35
ybt/1269/1269.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 505,
M = 6005;
int n, m, v[N], w[N], s[N], f[M], ans;
int main() {
std::ios::sync_with_stdio(false);
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 k = 1; k <= s[i]; k++) {
for (int j = m; j >= v[i]; j--) {
f[j] = std::max(f[j], f[j - v[i]] + w[i]);
}
}
}
for (int i = 0; i <= m; i++) {
ans = std::max(ans, f[i]);
}
cout << ans << endl;
return 0;
}