lanqiao 1176 小明的背包3(多重背包)
This commit is contained in:
25
00lanqiao chap/test100-1-5.cpp
Normal file
25
00lanqiao chap/test100-1-5.cpp
Normal 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
|
||||||
|
*/
|
||||||
Reference in New Issue
Block a user