logo AlgoBeat OnlineJudge
登录 注册

#102247. [BZOJ 2247] Pku3900 The Robbery

内存限制:64 MiB 时间限制:5000 ms 标准输入输出
题目类型:传统 评测方式:文本比较
上传者: 匿名

题目描述

In the downtown of Bucharest there is a very big bank with a very big vault. Inside the vault there are very big boxes numbered from . Inside the box with number there are very big diamonds, each of weight and cost .

John and Brus are inside the vault at the moment. They would like to steal everything, but unfortunately they are able to carry diamonds with the total weight not exceeding .

Your task is to help John and Brus to choose diamonds with the total weight less than or equal to and the maximal possible total cost.

中文翻译

在 Bucharest 市的市区里有一个很大的银行,银行的金库中有标号为 种盒子,第 个盒子中有 个重量为 ,价值为 的钻石。

John 和 Brus 正在金库中行窃,他们本想带走所有钻石,可惜他们的背包容量只有 ,换句话说,设 为他们带走的钻石标号集合,那么 需满足

你需要帮助 John 和 Brus,使得在满足这个条件下,最大化

输入格式

The first line contains single integer – the number of test cases. Each test case starts with a line containing two integers and separated by a single space. The next line contains integers separated by single spaces. The following line contains integers separated by single spaces.

第一行一个整数 ,表示数据组数。

对于每组数据,第一行包括两个正整数

接下来一行 个正整数,第 个整数表示

接下来一行 个正整数,第 个整数表示

输出格式

For each test case print a single line containing the maximal possible total cost of diamonds.

对每组数据,输出对应的最大价值。

样例

样例输入 #1

2 
2 4 
3 2 
5 3 
3 100 
4 7 1 
5 9 2

样例输出 #1

6 
29

数据范围与提示

Seerc2009