题库练习 Download More RAM
← 上一题 下一题 →

A14800 | Download More RAM

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Did you know you can download more RAM? There is a shop with $n$ different pieces of software that increase your RAM. The $i$ -th RAM increasing software takes $a_i$ GB of memory to run (temporarily, once the program is done running, you get the RAM back), and gives you an additional $b_i$ GB of RAM (permanently). Each software can only be used once. Your PC currently has $k$ 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 $t$ ( $1 \le t \le 100$ ) — the number of test cases. The description of test cases follows.

The first line of each test case contains the integers $n$ and $k$ ( $1 \le n \le 100$ , $1 \le k \le 1000$ ). Then two lines follow, each containing $n$ integers describing the arrays $a$ and $b$ ( $1 \le a_i, b_i \le 1000$ ).

输出格式

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

输入输出样例

输入 #1
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
输出 #1
29
6
1
256
C++ 编辑器
输入
输出