| 2026 华南师范大学程序设计竞赛 (SCNUCPC 2026) |
|---|
| Закончено |
Emolga, who keeps trying to become a top student, can now count more and more cubes! It is getting closer and closer to its dream — getting into Supreme Cheese National University and majoring in Cheese Statistics.
Emolga wants to stack some unit cubes in an $$$n\times m$$$ area on the ground.
It made a blueprint showing the front view and the left view of the cube tower. For simplicity, it only writes the visible stacking height at each horizontal position in that view.
Your task is to tell Emolga whether it is possible to build a tower matching the blueprint.
Each test file contains multiple test cases. The first line contains an integer $$$T$$$ $$$(1 \leq T \leq 10^4)$$$, the number of test cases.
For each test case:
The first line contains two integers $$$n,m$$$ $$$(1\leq n,m \leq 2\times 10^5)$$$, representing the size of the stacking area;
The second line contains $$$n$$$ integers $$$a_i$$$ $$$(0 \leq a_i \leq 10^9)$$$, representing the stacking heights in the left view;
The third line contains $$$m$$$ integers $$$b_j$$$ $$$(0 \leq b_j \leq 10^9)$$$, representing the stacking heights in the front view.
It is guaranteed that, in a single test file, the sum of $$$n\times m$$$ over all test cases does not exceed $$$2 \times 10^5$$$.
For each test case, print one line with Yes if there is a solution; otherwise, print one line with No.
23 52 1 02 0 0 1 03 50 0 10 1 2 3 0
YesNo
For the first test case in the sample, the corresponding front view, left view, and one valid stacking are as follows:
For the third test case in the sample, it can be proved that there is no valid stacking.
| Название |
|---|


