Problem C

Statement
Copy Copied
C. Dungeontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou 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 > 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.InputEach 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.OutputFor each test case output one integer β€” the maximum number of monsters you can kill.ExampleInput53 22 2 22 33 22 32 32 3 40 0 03 51 7 76 6 2 2 22 0 0 7 24 41 5 3 57 4 6 50 0 1 62 21 10000000001000000000 11000000000 0Output22532NoteVisualizer linkIn 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.