题库练习 Hemose Shopping
← 上一题 下一题 →

A14621 | Hemose Shopping

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Hemose was shopping with his friends Samez, AhmedZ, AshrafEzz, TheSawan and O\_E in Germany. As you know, Hemose and his friends are problem solvers, so they are very clever. Therefore, they will go to all discount markets in Germany.

Hemose has an array of $n$ integers. He wants Samez to sort the array in the non-decreasing order. Since it would be a too easy problem for Samez, Hemose allows Samez to use only the following operation:

- Choose indices $i$ and $j$ such that $1 \le i, j \le n$ , and $\lvert i - j \rvert \geq x$ . Then, swap elements $a_i$ and $a_j$ .

Can you tell Samez if there's a way to sort the array in the non-decreasing order by using the operation written above some finite number of times (possibly $0$ )?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $t$ $(1 \leq t \leq 10^5)$ . Description of the test cases follows.

The first line of each test case contains two integers $n$ and $x$ $(1 \leq x \leq n \leq 10^5)$ .

The second line of each test case contains $n$ integers $a_1, a_2, ..., a_n$ $(1 \leq a_i \leq 10^9)$ .

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $2 \cdot 10^5$ .

输出格式

For each test case, you should output a single string.

If Samez can sort the array in non-decreasing order using the operation written above, output "YES" (without quotes). Otherwise, output "NO" (without quotes).

You can print each letter of "YES" and "NO" in any case (upper or lower).

输入输出样例

输入 #1
4
3 3
3 2 1
4 3
1 2 3 4
5 2
5 1 2 3 4
5 4
1 2 3 4 4
输出 #1
NO
YES
YES
YES
C++ 编辑器
输入
输出