标签:center sem rip get select ota cep from stream
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 7585 Accepted Submission(s): 2427
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int dp[1005][105]; int cost,val; int n,m,l; void zero_one(int cost,int val) { for(int j=l;j>=cost;j--) for(int k=m;k>=1;k--) if(dp[j-cost][k-1]>=0) dp[j][k]=max(dp[j][k],dp[j-cost][k-1]+val); } int main() { int t; scanf("%d",&t); while(t--) { memset(dp,-1,sizeof(dp)); dp[0][0]=0; scanf("%d%d%d",&n,&m,&l); for(int i=0;i<n;i++) { scanf("%d%d",&cost,&val); zero_one(cost,val); } int res=0; for(int i=1;i<=l;i++) if(res<dp[i][m]) res=dp[i][m]; printf("%d\n",res); } return 0; }
标签:center sem rip get select ota cep from stream
原文地址:http://www.cnblogs.com/jasonlixuetao/p/6391398.html