#K78952. Organize Books on Shelf

    ID: 35200 Type: Default 1000ms 256MiB

Organize Books on Shelf

Organize Books on Shelf

You are given a shelf with n books, each labeled with a unique integer. Your task is to determine whether it is possible to sort the books in non-decreasing order using at most k adjacent swaps. An adjacent swap means swapping two neighboring books.

The minimum number of swaps required can be intuitively thought of as the sum of distances each book must travel from its current position to its correct position. In mathematical terms, if you denote by \( j_i \) the current position of the book that should be at position \( i \) in the sorted order, then an approximate measure is given by \( \sum_{i=1}^{n} |i - j_i| \). However, note that the optimal strategy might be more complex, and you are only required to check if sorting is possible within the allowed k swaps using a given strategy.

If it is possible, output YES; otherwise, output NO.

Example:

Input:
1
5 10
4 3 2 1 5

Output: YES

</p>

inputFormat

The first line of input contains a single integer T representing the number of test cases. Each test case is described as follows:

  • The first line contains two integers n and k, where n is the number of books and k is the maximum number of allowed adjacent swaps.
  • The second line contains n space-separated integers representing the identifiers of the books.

outputFormat

For each test case, output a single line containing YES if the books can be sorted using at most k swaps, or NO otherwise.

## sample
1
5 10
4 3 2 1 5
YES

</p>