标签:des style blog http color os io java ar
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 30486 Accepted Submission(s):
12550
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstring> 5 using namespace std; 6 7 int main () 8 { 9 int t; 10 int dp[1010],v[1010],w[1010]; 11 12 while (cin>>t) 13 { 14 while (t--) 15 { 16 memset(dp,0,sizeof(dp)); 17 int n,V,i,j; 18 cin>>n>>V; 19 for ( i=1; i<=n; i++) 20 cin>>w[i]; 21 for (i=1; i<=n; i++) 22 cin>>v[i]; 23 for (i=1; i<=n; i++) 24 { 25 for (j=V; j>=v[i]; j--) 26 { 27 dp[j]=max(dp[j],dp[j-v[i]]+w[i]); 28 //cout<<dp[j]<<" "<<v[i]<<endl; 29 } 30 } 31 printf ("%d\n",dp[V]); 32 } 33 34 } 35 return 0; 36 }
hdu 2602 Bone Collector (简单01背包)
标签:des style blog http color os io java ar
原文地址:http://www.cnblogs.com/qq-star/p/3962633.html