Codeforces Round 1003 (Div. 4) |
---|
Finished |
This is the easy version of the problem. In this version, $$$m = 1$$$.
Skibidus has obtained two arrays $$$a$$$ and $$$b$$$, containing $$$n$$$ and $$$m$$$ elements respectively. For each integer $$$i$$$ from $$$1$$$ to $$$n$$$, he is allowed to perform the operation at most once:
Skibidus needs your help determining whether he can sort $$$a$$$ in non-decreasing order$$$^{\text{∗}}$$$ by performing the above operation some number of times.
$$$^{\text{∗}}$$$$$$a$$$ is sorted in non-decreasing order if $$$a_1 \leq a_2 \leq \ldots \leq a_n$$$.
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$, $$$\textbf{m = 1}$$$).
The following line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$).
The following line of each test case contains $$$m$$$ integers $$$b_1, b_2, \ldots, b_m$$$ ($$$1 \leq b_i \leq 10^9$$$).
It is guaranteed that the sum of $$$n$$$ and the sum of $$$m$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, if it is possible to sort $$$a$$$ in non-decreasing order, print "YES" on a new line. Otherwise, print "NO" on a new line.
You can output the answer in any case. For example, the strings "yEs", "yes", and "Yes" will also be recognized as positive responses.
51 1593 11 4 334 11 4 2 564 15 4 10 543 19 8 78
YES NO YES NO YES
In the first test case, $$$[5]$$$ is already sorted.
In the second test case, it can be shown that it is impossible.
In the third test case, we can set $$$a_3:=b_1-a_3=6-2=4$$$. The sequence $$$[1,4,4,5]$$$ is in nondecreasing order.
In the last case, we can apply operations on each index. The sequence becomes $$$[-1,0,1]$$$, which is in nondecreasing order.
Name |
---|