标签:des style blog io color os sp java for
Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2534 Accepted Submission(s): 1138
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 6 int dp[105][105][6]; 7 inline int max(int a,int b){return a>b?a:b;} 8 int main() 9 { 10 int n,v1,v2,k,i,j,x,y,a,b,val; 11 while(~scanf("%d%d%d%d",&n,&v1,&v2,&k)) 12 { 13 memset(dp,0,sizeof(dp)); 14 for(i=1;i<=n;i++) 15 { 16 scanf("%d%d%d",&a,&b,&val); 17 for(j=v1;j>=0;j--) 18 for(x=v2;x>=0;x--) 19 for(y=k;y>=0;y--) 20 { 21 int temp=0; 22 if(j>=a)temp=max(temp,dp[j-a][x][y]+val);//用钱买 23 if(x>=b)temp=max(temp,dp[j][x-b][y]+val);//用积分换 24 if(y>=1)temp=max(temp,dp[j][x][y-1]+val);//免费拿 25 temp=max(temp,dp[j][x][y]);//不要 26 dp[j][x][y]=temp; 27 } 28 } 29 printf("%d\n",dp[v1][v2][k]); 30 } 31 return 0; 32 }
标签:des style blog io color os sp java for
原文地址:http://www.cnblogs.com/xiong-/p/4100879.html