标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 22865 Accepted Submission(s): 9661
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<map> 5 #include<queue> 6 #include<stack> 7 using namespace std; 8 int t; 9 int n,m; 10 struct node 11 { 12 int p,h,c; 13 }N[105]; 14 int f[105]; 15 int main() 16 { 17 while(scanf("%d",&t)!=EOF) 18 { 19 for(int i=1;i<=t;i++) 20 { 21 memset(f,0,sizeof(f)); 22 scanf("%d %d",&n,&m); 23 for(int j=1;j<=m;j++) 24 scanf("%d %d %d",&N[j].p,&N[j].h,&N[j].c); 25 for(int j=1;j<=m;j++) 26 { 27 for(int k=1;k<=N[j].c;k++) 28 { 29 for(int gg=n;gg>=N[j].p;gg--) 30 f[gg]=max(f[gg],f[gg-N[j].p]+N[j].h); 31 } 32 } 33 cout<<f[n]<<endl; 34 } 35 } 36 return 0; 37 }
标签:
原文地址:http://www.cnblogs.com/hsd-/p/5447718.html