Codeforces Global Round 30 (Div. 1 + Div. 2)
C
Dungeon
Codeforces
1400
原题
← BD →
翻译中…

You are now in a dungeon with $n$ swords, facing $m$ monsters.

翻译中…

The damage of the $i$-th sword is $a_i$, and the life value of the $i$-th monster is $b_i$. A sword with damage $x$ can kill a monster with life value $y$ if and only if $x \ge y$.

翻译中…

After killing the $i$-th monster with a sword of damage $x$, this sword disappears. Then, if $c_i \gt 0$, you will obtain a new sword with damage $\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.

翻译中…

Input

翻译中…

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

翻译中…

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

翻译中…

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9)$.

翻译中…

The third line of each test case contains $m$ integers $b_1, b_2, \ldots, b_m$ ($1 \le b_i \le 10^9)$.

翻译中…

The fourth line of each test case contains $m$ integers $c_1, c_2, \ldots, c_m$ ($0 \le c_i \le 10^9)$.

翻译中…

It is guaranteed that the sum of $n$ and $m$ over all test cases does not exceed $2 \cdot 10^5$, respectively.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…
翻译中…

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 $c_i=0$, so you can only kill monster #1 and #2 with your two existing swords.

翻译中…

样例

Input #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
Output #1
2
2
5
3
2
InputCopy OutputCopy
题目信息
题号
2164C
时间限制
2 s
内存限制
256 MB
标签
二分
暴力
数据结构
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。