CF1903A.Halloumi Boxes

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Halloumi Boxes

Theofanis is busy after his last contest, as now, he has to deliver many halloumis all over the world. He stored them inside nn boxes and each of which has some number aia_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 kk.

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

^{\dagger} Reversing a subarray means choosing two indices ii and jj (where 1ijn1 \le i \le j \le n) and changing the array a1,a2,,ana_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 ji+1j - i + 1.

Input

The first line contains a single integer tt (1t1001 \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 nn and kk (1kn1001 \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 nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \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.

Samples

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
YES
YES
YES
YES
NO

在线编程 IDE

建议全屏模式获得最佳体验