3
7 40 3
5 23 8
2 52 6
48
N < = 400 , H_i < = 100 , C_i < = 10 , A_i < = 40000
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<vector> using namespace std; int n; int H,C,A; struct BOX { int h,a,c; }box[405]; bool cmp(BOX x,BOX y) { return x.a<y.a; } int main() { cin>>n; int num=1; for(int i=1;i<=n;i++) { cin>>box[i].h>>box[i].a>>box[i].c; } sort(box+1,box+1+n,cmp); bool f[40010]; memset(f,0,sizeof(f)); f[0]=1; int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=box[i].c;j++) { for(int k=box[i].a;k>=box[i].h;k--) { if(f[k-box[i].h]) f[k]=1; if(f[k]) ans = max(ans,k); } } } cout<<ans; return 0; }
原文:https://www.cnblogs.com/caiyishuai/p/10456345.html