//01背包模板
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1010101;
int dp[N];
int v[N],w[N];
int main()
{
int n;
scanf("%d",&n);
while(n --)
{
memset(dp,0,sizeof(dp));
int spci,money;
scanf("%d%d",&spci,&money);
for(int i = 1;i <= spci;i ++) scanf("%d",&v[i]);
for(int i = 1;i <= spci;i ++) scanf("%d",&w[i]);
for(int i = 1;i <= spci;i ++)
for(int j = money;j >= w[i];j --)
{
dp[j] = max(dp[j],dp[j - w[i]] + v[i]);
}
printf("%d\n",dp[money]);
}
}
HDU - 2602 Bone Collector
最新推荐文章于 2024-11-01 17:00:11 发布