- 实现多重背包
问题,不是ac答案
- 2023-12-31 9:36:04 @
#include<bits/stdc++.h>
using namespace std;
long long w[10005],c[10005],a[10005],dp[10005];
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>w[i]>>c[i]>>a[i];
}
for(int i=1;i<=n;i++){
for(int j=c[i];j<=m;j++){
if(a[i]--) dp[j]=max(dp[j],dp[j-c[i]]+w[i]);
}
}
cout<<dp[m];
return 0;
}
1 comments
-
wenhaoyu LV 4 @ 2024-1-22 12:20:01
jahqwgswgx
- 1
Information
- ID
- 1118
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 38
- Accepted
- 13
- Uploaded By