Codeforces Round 672 (Div. 2)
A
Cubes Sorting
Codeforces
900
原题
←B →
翻译中…

For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got one hour! Solve it!

翻译中…

Wheatley decided to try to make a test chamber. He made a nice test chamber, but there was only one detail absent — cubes.

翻译中…

For completing the chamber Wheatley needs $n$ cubes. $i$-th cube has a volume $a_i$.

翻译中…

Wheatley has to place cubes in such a way that they would be sorted in a non-decreasing order by their volume. Formally, for each $i \gt 1$, $a_{i-1} \le a_i$ must hold.

翻译中…

To achieve his goal, Wheatley can exchange two neighbouring cubes. It means that for any $i \gt 1$ you can exchange cubes on positions $i-1$ and $i$.

翻译中…

But there is a problem: Wheatley is very impatient. If Wheatley needs more than $\frac{n \cdot (n-1)}{2}-1$ exchange operations, he won't do this boring work.

翻译中…

Wheatly wants to know: can cubes be sorted under this conditions?

翻译中…

Input

翻译中…

Each test contains multiple test cases.

翻译中…

The first line contains one positive integer $t$ ($1 \le t \le 1000$), denoting the number of test cases. Description of the test cases follows.

翻译中…

The first line of each test case contains one positive integer $n$ ($2 \le n \le 5 \cdot 10^4$) — number of cubes.

翻译中…

The second line contains $n$ positive integers $a_i$ ($1 \le a_i \le 10^9$) — volumes of cubes.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.

翻译中…

Note

翻译中…

In the first test case it is possible to sort all the cubes in $7$ exchanges.

翻译中…

In the second test case the cubes are already sorted.

翻译中…

In the third test case we can make $0$ exchanges, but the cubes are not sorted yet, so the answer is "NO".

翻译中…

样例

Input #1
3
5
5 3 2 1 4
6
2 2 2 2 2 2
2
2 1
Output #1
YES
YES
NO
InputCopy OutputCopy
题目信息
题号
1420A
时间限制
1 s
内存限制
256 MB
标签
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。