CF2164C.Dungeon

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are now in a dungeon with nn swords, facing mm monsters.

The damage of the ii-th sword is aia_i, and the life value of the ii-th monster is bib_i. A sword with damage xx can kill a monster with life value yy if and only if x≥yx \ge y.

After killing the ii-th monster with a sword of damage xx, this sword disappears. Then, if ci>0c_i \gt 0, you will obtain a new sword with damage max⁡(x,ci)\max(x, c_i); otherwise, you gain nothing.

Now you want to know the maximum number of monsters you can kill. Note that you can kill each monster at most once.

你现在身处一个地牢中,面前有 nn 把剑和 mm 只怪物。

第 ii 把剑的伤害值为 aia_i,第 ii 只怪物的生命值为 bib_i。当且仅当剑的伤害值 xx 满足 x≥yx \ge y 时,该剑才能击杀生命值为 yy 的怪物。

用伤害值为 xx 的剑击杀第 ii 只怪物后,这把剑将消失。随后,若 ci>0c_i > 0,你将获得一把新剑,其伤害值为 max⁡(x,ci)\max(x, c_i);否则,你不会获得任何新剑。

现在你想知道最多能击杀多少只怪物。注意:每只怪物至多被击杀一次。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases TT (1≤T≤1041 \le T \le 10^4). The description of the test cases follows.

The first line of each test case contains two integers nn and mm (1≤n,m≤2⋅1051 \le n,m \le 2 \cdot 10^5).

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤109)1 \le a_i \le 10^9).

The third line of each test case contains mm integers b1,b2,…,bmb_1, b_2, \ldots, b_m (1≤bi≤109)1 \le b_i \le 10^9).

The fourth line of each test case contains mm integers c1,c2,…,cmc_1, c_2, \ldots, c_m (0≤ci≤109)0 \le c_i \le 10^9).

It is guaranteed that the sum of nn and mm over all test cases does not exceed 2⋅1052 \cdot 10^5, respectively.

每个测试包含多个测试用例。第一行包含测试用例的数量 TT(1≤T≤1041 \le T \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含两个整数 nn 和 mm(1≤n,m≤2⋅1051 \le n,m \le 2 \cdot 10^5)。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9)。

每个测试用例的第三行包含 mm 个整数 b1,b2,…,bmb_1, b_2, \ldots, b_m(1≤bi≤1091 \le b_i \le 10^9)。

每个测试用例的第四行包含 mm 个整数 c1,c2,…,cmc_1, c_2, \ldots, c_m(0≤ci≤1090 \le c_i \le 10^9)。

保证所有测试用例中 nn 的总和与 mm 的总和分别均不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case output one integer — the maximum number of monsters you can kill.

对于每个测试用例,输出一个整数——你能杀死的怪物的最大数量。

输入输出样例

  • 输入#1

    5
    3 2
    2 2 2
    2 3
    3 2
    2 3
    2 3
    2 3 4
    0 0 0
    3 5
    1 7 7
    6 6 2 2 2
    2 0 0 7 2
    4 4
    1 5 3 5
    7 4 6 5
    0 0 1 6
    2 2
    1 1000000000
    1000000000 1
    1000000000 0

    输出#1

    2
    2
    5
    3
    2

说明/提示

Visualizer link

In the first test case, you can first kill monster #1 using sword #1, and obtain a new sword with damage max⁡(2,3)=3\max(2,3)=3. You can then use this sword to kill monster #2.

In the second test case, you can't obtain any new swords because all ci=0c_i=0, so you can only kill monster #1 and #2 with your two existing swords.

可视化链接

在第一个测试用例中,你可以首先使用剑 #1 击杀怪物 #1,并获得一把新剑,其伤害值为 max⁡(2,3)=3\max(2,3)=3。接着,你可以使用这把新剑击杀怪物 #2。

在第二个测试用例中,由于所有 ci=0c_i=0,你无法获得任何新剑,因此只能用已有的两把剑击杀怪物 #1 和 #2。

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

首页