Problem Descriptionmany years ago, in Teddy ' s hometown there is a man who was called "Bone Collector". Collect varies of bones, such as dog ' s, cow ' s, also he went to the grave ...
The bone collector had a big bag with a volume of V, and along he trip of collecting there is a lot of bones, obviously , different bone have different value and different volume, now given the each bone's value along his trips, can you CALCU Late out the maximum of the total value the bone collector can get?
Inputthe first line contain a integer T, the number of cases.
Followed by T cases, each case three lines, the first line contain both integer n, V, (N <=, v <=) repr Esenting the number of bones and the volume of his bag. And the second line contain N integers representing the value of each bone. The third line contain N integers representing the volume for each bone.
Outputone integer per line representing the maximum of the total value (this number would be is less than 231).
Sample Input15 101 2 3 4 55 4 3 2 1
Sample Output14
01 Backpack:
1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <math.h>5#include <algorithm>6#include <iostream>7 using namespacestd;8 intdp[10000];9 Ten intMain () One { A intt,i,j,n,v; -scanf"%d",&t); - while(t--){ the inta[10000]; - intb[10000]; -Memset (DP,0,sizeof(DP)); -scanf"%d%d",&n,&v); + for(i=1; i<=n;i++) -scanf"%d",&a[i]); + for(i=1; i<=n;i++) Ascanf"%d",&b[i]); at for(i=1; i<=n;i++){ - for(j=v;j>=b[i];j--){ -Dp[j]=max (dp[j],dp[j-b[i]]+a[i]); - } - } -printf"%d\n", Dp[v]); in } - return 0; to}
HDU 2602--bone Collector