Codeforces Round 737 (Div. 2)
B
Moamen and k-subarrays
Codeforces
1100
原题
← AC →
翻译中…

Moamen has an array of $n$ distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once:

翻译中…
  1. Split the array into exactly $k$ non-empty subarrays such that each element belongs to exactly one subarray.
  2. Reorder these subarrays arbitrary.
  3. Merge the subarrays in their new order.
翻译中…

A sequence $a$ is a subarray of a sequence $b$ if $a$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

翻译中…

Can you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 10^3$) — the number of test cases. The description of the test cases follows.

翻译中…

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

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le |a_i| \le 10^9$). It is guaranteed that all numbers are distinct.

翻译中…

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

翻译中…

Output

翻译中…

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

翻译中…

If Moamen can sort the array in non-decreasing order, output "YES" (without quotes). Otherwise, output "NO" (without quotes).

翻译中…

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

翻译中…

Note

翻译中…

In the first test case, $a = [6, 3, 4, 2, 1]$, and $k = 4$, so we can do the operations as follows:

翻译中…
  1. Split $a$ into $\{ [6], [3, 4], [2], [1] \}$.
  2. Reorder them: $\{ [1], [2], [3,4], [6] \}$.
  3. Merge them: $[1, 2, 3, 4, 6]$, so now the array is sorted.
翻译中…

In the second test case, there is no way to sort the array by splitting it into only $2$ subarrays.

翻译中…

As an example, if we split it into $\{ [1, -4], [0, -2] \}$, we can reorder them into $\{ [1, -4], [0, -2] \}$ or $\{ [0, -2], [1, -4] \}$. However, after merging the subarrays, it is impossible to get a sorted array.

翻译中…

样例

Input #1
3
5 4
6 3 4 2 1
4 2
1 -4 0 -2
5 1
1 2 3 4 5
Output #1
Yes
No
Yes
InputCopy OutputCopy
题目信息
题号
1557B
时间限制
2 s
内存限制
256 MB
标签
贪心
排序

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