Codeforces Round 912 (Div. 2)
A
Halloumi Boxes
Codeforces
800
原题
←B →
翻译中…

Theofanis is busy after his last contest, as now, he has to deliver many halloumis all over the world. He stored them inside $n$ boxes and each of which has some number $a_i$ written on it.

翻译中…

He wants to sort them in non-decreasing order based on their number, however, his machine works in a strange way. It can only reverse any subarray$^{\dagger}$ of boxes with length at most $k$.

翻译中…

Find if it's possible to sort the boxes using any number of reverses.

翻译中…

$^{\dagger}$ Reversing a subarray means choosing two indices $i$ and $j$ (where $1 \le i \le j \le n$) and changing the array $a_1, a_2, \ldots, a_n$ to $a_1, a_2, \ldots, a_{i-1}, \; a_j, a_{j-1}, \ldots, a_i, \; a_{j+1}, \ldots, a_{n-1}, a_n$. The length of the subarray is then $j - i + 1$.

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases.

翻译中…

Each test case consists of two lines.

翻译中…

The first line of each test case contains two integers $n$ and $k$ ($1 \le k \le n \le 100$) — the number of boxes and the length of the maximum reverse that Theofanis can make.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{9}$) — the number written on each box.

翻译中…

Output

翻译中…

For each test case, print YES (case-insensitive), if the array can be sorted in non-decreasing order, or NO (case-insensitive) otherwise.

翻译中…

Note

翻译中…

In the first two test cases, the boxes are already sorted in non-decreasing order.

翻译中…

In the third test case, we can reverse the whole array.

翻译中…

In the fourth test case, we can reverse the first two boxes and the last two boxes.

翻译中…

In the fifth test case, it can be shown that it's impossible to sort the boxes.

翻译中…

样例

Input #1
5
3 2
1 2 3
3 1
9 9 9
4 4
6 4 2 1
4 3
10 3 830 14
2 1
3 1
Output #1
YES
YES
YES
YES
NO
InputCopy OutputCopy
题目信息
题号
1903A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
排序

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