标签:style blog http java color strong
1 5 10 1 2 3 4 5 5 4 3 2 1
14
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <vector> 6 #include <climits> 7 #include <ctype.h> 8 #include <cmath> 9 #include <algorithm> 10 #define LL long long 11 using namespace std; 12 int v[1001],w[1001],dp[1001]; 13 int main(){ 14 int kase,i,j,n,m; 15 scanf("%d",&kase); 16 while(kase--){ 17 memset(dp,0,sizeof(dp)); 18 scanf("%d %d",&n,&m); 19 for(i = 1; i <= n; i++) 20 scanf("%d",v+i); 21 for(i = 1; i <= n; i++) 22 scanf("%d",w+i); 23 for(i = 1; i <= n; i++){ 24 for(j = m; j >= w[i]; j--){ 25 dp[j] = max(dp[j],dp[j-w[i]]+v[i]); 26 } 27 } 28 printf("%d\n",dp[m]); 29 } 30 return 0; 31 }
BNUOJ 6727 Bone Collector,布布扣,bubuko.com
标签:style blog http java color strong
原文地址:http://www.cnblogs.com/crackpotisback/p/3831619.html