标签:des style blog http color os strong io
Description
Input
Output
Sample Input
Sample Output
1 Home Problems Status Contest [xiong_tao] Logout 2 xiong_tao ‘s source code for F 3 Memory: 4908 KB Time: 265 MS 4 Language: G++ Result: Accepted 5 6 1 7 2 8 3 9 4 10 5 11 6 12 7 13 8 14 9 15 10 16 11 17 12 18 13 19 14 20 15 21 16 22 17 23 18 24 19 25 20 26 21 27 22 28 23 29 24 30 25 31 26 32 27 33 28 34 29 35 36 #include<cstdio> 37 #include<string.h> 38 using namespace std; 39 int p[120],m[120],v[120],dp[120][10010]; 40 int max1(int x,int y,int z) 41 { 42 x=x>y?x:y; 43 x=x>z?x:z; 44 return x; 45 } 46 int main() 47 { 48 int n,d,k; 49 int i,j,a; 50 while(scanf("%d%d%d",&n,&d,&k)!=EOF) 51 { 52 for(i=0; i<n; i++) 53 scanf("%d%d%d",&p[i],&m[i],&v[i]); 54 memset(dp,0,sizeof(dp)); 55 for(i=1; i<=k; i++) 56 for(j=0; j<n; j++) 57 for(a=d; a>=0; a--) 58 if(a>=m[j]&&p[j]==i) 59 dp[i][a]=max1(dp[i-1][a-m[j]]+v[j],dp[i][a],dp[i][a-m[j]]+v[j]); 60 if(dp[k][d]) printf("%d\n",dp[k][d]); 61 else printf("Impossible\n"); 62 } 63 return 0; 64 } 65 66 FAQ | About Virtual Judge | Forum | Discuss | Open Source Project 67 All Copyright Reserved ©2010-2012 HUST ACM/ICPC TEAM 68 Anything about the OJ, please ask in the forum, or contact author:Isun 69 Server Time: 2014-07-28 20:21:39
标签:des style blog http color os strong io
原文地址:http://www.cnblogs.com/angledamon/p/3873927.html