【无标题】

Download More RAM

描述:

Did you know you can download more RAM? There is a shop with n different pieces of software that increase your RAM. The ii-th RAM increasing software takes a

GB of memory to run (temporarily, once the program is done running, you get the RAM back), and gives you an additional bibi GB of RAM (permanently). Each software can only be used once. Your PC currently has kk GB of RAM.

Note that you can't use a RAM-increasing software if it takes more GB of RAM to use than what you currently have.

Since RAM is the most important thing in the world, you wonder, what is the maximum possible amount of RAM achievable?

输入:

The first line of the input contains a single integer tt (1≤t≤100) — the number of test cases. The description of test cases follows.

The first line of each test case contains the integers nn and kk (1≤n≤1001≤n≤100, 1≤k≤10001≤k≤1000). Then two lines follow, each containing nn integers describing the arrays aa and bb (1≤ai,bi≤10001≤ai,bi≤1000).

输出:

For each test case, output a single line containing the largest amount of RAM you can achieve.

样例输入:

4
3 10
20 30 10
9 100 10
5 1
1 1 5 1 1
1 1 1 1 1
5 1
2 2 2 2 2
100 100 100 100 100
5 8
128 64 32 16 8
128 64 32 16 8

复制

样例输出:

29
6
1
256

复制

注释:

In the first test case, you only have enough RAM to run the third software initially, but that increases your RAM to 2020 GB, which allows you to use the first software, increasing your RAM to 2929 GB. The only software left needs 3030 GB of RAM, so you have to stop here.

In the second test case, you can use the first, second, fourth and fifth software that need only 11 GB of RAM per software to run to increase your RAM to 55 GB, and then use the last remaining one to increase your RAM to 66 GB.

In the third test case, all the software need more than 11 GB of RAM to run, so the amount of RAM you have stays at 11 GB.

翻译

你知道你可以下载更多的内存吗?有一家商店有n种不同的软件,可以增加你的内存。第i个RAM增加软件需要ai GB的内存来运行(暂时,一旦程序运行完毕,您就可以重新获得RAM),并提供额外的bi GB内存(永久)。每个软件只能使用一次。你的电脑目前有k GB的内存。
请注意,如果需要使用比当前更多GB的RAM,则不能使用增加RAM的软件。
由于RAM是世界上最重要的东西,你想知道,最大可能达到的RAM量是多少?

输入:
输入的第一行包含一个整数t(1≤T≤100)-测试用例的数量。测试用例的描述如下。
每个测试用例的第一行包含整数n和k(1)≤N≤100, 1≤K≤1000). 接下来是两行,每行包含n个整数,描述数组a和b(1≤ai,比bi≤1000).
输出:
对于每个测试用例,输出一行,其中包含可以实现的最大RAM量。

样例输入:

4
3 10
20 30 10
9 100 10
5 1
1 1 5 1 1
1 1 1 1 1
5 1
2 2 2 2 2
100 100 100 100 100
5 8
128 64 32 16 8
128 64 32 16 8

复制

样例输出:

29
6
1
256

注释

在第一个测试用例中,最初只有足够的RAM来运行第三个软件,但这会将RAM增加到20GB,这允许您使用第一个软件,将RAM增加到29GB。剩下的唯一软件需要30GB的内存,所以你只能到此为止。
在第二个测试用例中,您可以使用第一个、第二个、第四个和第五个软件,每个软件只需要1 GB的RAM即可将RAM增加到5 GB,然后使用最后一个剩余的软件将RAM增加到6 GB。
在第三个测试用例中,所有软件都需要超过1GB的RAM才能运行,因此您拥有的RAM量保持在1GB。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值