C2. Skibidus and Fanum Tax (hard version)
This is the hard version of the problem. In this version,
Skibidus has obtained two arrays
- Choose an integer
j such that1≤j≤m . Setai:=bj−ai . Note thatai may become non-positive as a result of this operation.
Skibidus needs your help determining whether he can sort
The first line contains an integer
The first line of each test case contains two integers
The following line of each test case contains
The following line of each test case contains
It is guaranteed that the sum of
For each test case, if it is possible to sort
You can output the answer in any case. For example, the strings "yEs", "yes", and "Yes" will also be recognized as positive responses.
51 359 1 10000000003 21 4 33 44 32 4 6 56 1 85 26 4 5 4 54 10003 19 8 78
YES NO YES NO YES
In the first test case,
In the second test case, it can be shown that it is impossible.
In the third test case, we can set
In the last case, we can apply operations on each index. The sequence becomes