CF2164C.Dungeon
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are now in a dungeon with n swords, facing m monsters.
The damage of the i-th sword is ai, and the life value of the i-th monster is bi. A sword with damage x can kill a monster with life value y if and only if x≥y.
After killing the i-th monster with a sword of damage x, this sword disappears. Then, if ci>0, you will obtain a new sword with damage max(x,ci); 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.
你现在身处一个地牢中,面前有 n 把剑和 m 只怪物。
第 i 把剑的伤害值为 ai,第 i 只怪物的生命值为 bi。当且仅当剑的伤害值 x 满足 x≥y 时,该剑才能击杀生命值为 y 的怪物。
用伤害值为 x 的剑击杀第 i 只怪物后,这把剑将消失。随后,若 ci>0,你将获得一把新剑,其伤害值为 max(x,ci);否则,你不会获得任何新剑。
现在你想知道最多能击杀多少只怪物。注意:每只怪物至多被击杀一次。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases T (1≤T≤104). The description of the test cases follows.
The first line of each test case contains two integers n and m (1≤n,m≤2⋅105).
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤109).
The third line of each test case contains m integers b1,b2,…,bm (1≤bi≤109).
The fourth line of each test case contains m integers c1,c2,…,cm (0≤ci≤109).
It is guaranteed that the sum of n and m over all test cases does not exceed 2⋅105, respectively.
每个测试包含多个测试用例。第一行包含测试用例的数量 T(1≤T≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含两个整数 n 和 m(1≤n,m≤2⋅105)。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)。
每个测试用例的第三行包含 m 个整数 b1,b2,…,bm(1≤bi≤109)。
每个测试用例的第四行包含 m 个整数 c1,c2,…,cm(0≤ci≤109)。
保证所有测试用例中 n 的总和与 m 的总和分别均不超过 2⋅105。
输出格式
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
说明/提示
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. 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=0, so you can only kill monster #1 and #2 with your two existing swords.
在第一个测试用例中,你可以首先使用剑 #1 击杀怪物 #1,并获得一把新剑,其伤害值为 max(2,3)=3。接着,你可以使用这把新剑击杀怪物 #2。
在第二个测试用例中,由于所有 ci=0,你无法获得任何新剑,因此只能用已有的两把剑击杀怪物 #1 和 #2。
输入解题思路,AI测评打分。不知道怎么写?