标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 16861 Accepted Submission(s):
7131
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define INF 0x3f3f3f int t,n,m; int dp[110]; struct rice { int p; int w; int num; }R[110]; void solve() { for(int i=1;i<=m;i++) { for(int k=1;k<=R[i].num;k++) { for(int j=n;j>=R[i].p;j--) { dp[j]=max(dp[j-R[i].p]+R[i].w,dp[j]); } } } printf("%d\n",dp[n]); } int main() { scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { scanf("%d%d%d",&R[i].p,&R[i].w,&R[i].num); } solve(); } return 0; }
hdu2191悼念512汶川大地震遇难同胞——珍惜现在,感恩生活(完全背包)
标签:
原文地址:http://www.cnblogs.com/qianyanwanyu--/p/4393797.html