CF1629A Download More RAM
题目描述
有一家商店有 $n$ 种不同的软件,可以增加你的内存。第 $i$ 个内存增加软件需要 $a_i$ GB 的内存来运行(这是暂时的。一旦程序运行完毕,您就可以恢复内存),并**永久**提供额外的 $b_i$ GB 内存。**每个软件只能使用一次**。您的电脑当前有 $k$ GB 内存。请注意,如果需要使用比当前更多 GB 的内存,则不能使用内存增加软件。
因为内存是世界上最重要的东西,你想知道,能运行的软件全部运行完后,可以达到的最大内存量是多少?
输入格式
输入的第一行包含一个整数 $t$ $(1 \leq t \leq 100)$,为测试用例的数量。测试用例的描述如下:
每个测试用例的第一行包含两个整数 $n$ 和 $k$ $(1 \leq n \leq 100,1 \leq K \leq 1000)$。接下来是两行,每行包含 $n$ 个整数,为数组 $a$ 和 $b$ $(1 \leq a_i,b_i \leq 1000)$。
输出格式
对于每个测试用例,输出一行一个整数,为可以达到的最大内存量。
说明/提示
In the first test case, you only have enough RAM to run the third software initially, but that increases your RAM to $ 20 $ GB, which allows you to use the first software, increasing your RAM to $ 29 $ GB. The only software left needs $ 30 $ 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 $ 1 $ GB of RAM per software to run to increase your RAM to $ 5 $ GB, and then use the last remaining one to increase your RAM to $ 6 $ GB.
In the third test case, all the software need more than $ 1 $ GB of RAM to run, so the amount of RAM you have stays at $ 1 $ GB.