CF1629A.Download More RAM

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Did you know you can download more RAM? There is a shop with nn different pieces of software that increase your RAM. The ii-th RAM increasing software takes aia_i GB of memory to run (temporarily, once the program is done running, you get the RAM back), and gives you an additional bib_i 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?

你知道吗?你可以下载更多的内存(RAM)!有一家商店出售 nn 种不同的软件,每种软件都能提升你的内存容量。第 ii 种内存提升软件在运行时需要占用 aia_i GB 的内存(临时占用;程序运行结束后,这部分内存会被释放),并永久为你增加 bib_i GB 的内存容量。每种软件最多只能使用一次。你当前的电脑拥有 kk GB 的内存。

注意:若某款内存提升软件运行所需内存(GB 数)超过了你当前拥有的内存容量,则你无法运行该软件。

由于内存是世界上最重要的东西,你不禁思考:最终能够达到的最大内存容量是多少?

输入格式

The first line of the input contains a single integer tt (1≤t≤1001 \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 nn and kk (1≤n≤1001 \le n \le 100, 1≤k≤10001 \le k \le 1000). Then two lines follow, each containing nn integers describing the arrays aa and bb (1≤ai,bi≤10001 \le a_i, b_i \le 1000).

输入的第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含两个整数 nn 和 kk(1≤n≤1001 \le n \le 100,1≤k≤10001 \le k \le 1000)。接下来是两行,每行包含 nn 个整数,分别描述数组 aa 和 bb(1≤ai,bi≤10001 \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

说明/提示

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.

在第一个测试用例中,你初始时仅有足够的内存运行第三个软件,运行后你的内存增加至 2020 GB,从而可以运行第一个软件,使内存进一步增加至 2929 GB。剩余唯一未运行的软件需要 3030 GB 内存,因此你只能在此停止。

在第二个测试用例中,你可以依次运行第一、第二、第四和第五个软件(每个仅需 11 GB 内存),使内存增加至 55 GB,然后运行最后一个软件,使内存进一步增加至 66 GB。

在第三个测试用例中,所有软件运行所需内存均超过 11 GB,因此你的内存始终保持在 11 GB。

输入解题思路,AI测评打分。不知道怎么写?

首页