Codeforces Round 998 (Div. 3) |
---|
Finished |
You are given a sequence $$$a$$$ consisting of $$$n$$$ positive integers.
You can perform the following operation any number of times.
Determine if it is possible to make the sequence non-decreasing by using the operation any number of times.
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 a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).
The second line of each test case contains $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le 10^9$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
If it is possible to make the sequence non-decreasing, 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.
551 2 3 4 544 3 2 144 5 2 384 5 4 5 4 5 4 599 9 8 2 4 4 3 5 3
YES NO YES YES NO
In the first test case, the array is already sorted.
In the second test case, we can show that it is impossible.
In the third test case, after performing an operation on $$$i=1$$$, the array becomes $$$[0,1,2,3]$$$, which is now in nondecreasing order.
Name |
---|