lanqiao 1176 小明的背包3(多重背包)

This commit is contained in:
2025-04-09 14:16:03 +08:00
parent 8fff611054
commit def86a6b23

View File

@@ -0,0 +1,25 @@
// lanqiao 1176 小明的背包3(多重背包)
#include <bits/stdc++.h>
using namespace std;
const int N = 2e2+10;
int dp[N];
int main(){
// 请在此输入您的代码
int n, m; cin >> n >> m;
for(int i = 1; i <= n; i++){
int w, v, s; cin >> w >> v >> s;
while(s--){
for(int j = m; j >= w; j--){
dp[j] = max(dp[j], dp[j-w] + v);
}
}
}
cout << dp[m] << '\n';
return 0;
}
/* test samples -> 39
3 30
1 2 3
4 5 6
7 8 9
*/