标签:this java font imp tin script put can word
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2915 Accepted Submission(s): 1036
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int dp[10005]; int cos,val,num[15][15]; int n,c; void zero_one(int cost,int val) { for(int j=c;j>=cost;j--) dp[j]=max(dp[j],dp[j-cost]+val); } int main() { while(scanf("%d%d",&n,&c)!=EOF) { memset(dp,0,sizeof(dp)); memset(num,0,sizeof(num)); for(int i=0;i<n;i++) { char str[20]; scanf("%s%d%d",str,&val,&cos); num[val][cos]++; } for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) { if(num[i][j]>0) { if(num[i][j]*j>c) for(int k=j;k<=c;k++) dp[k]=max(dp[k],dp[k-j]+i); else { int tmp=1,nu=num[i][j]; while(nu>tmp) { zero_one(j*tmp,i*tmp); nu-=tmp; tmp=tmp<<1; } zero_one(j*nu,i*nu); } } } printf("%d\n",dp[c]); } return 0; }
标签:this java font imp tin script put can word
原文地址:http://www.cnblogs.com/jasonlixuetao/p/6390844.html