description: 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 ≤ t ≤ 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 ≤ k ≤ n ≤ 10^5).
  
  The second line contains n integers a_1, a_2, …, a_n (0 ≤ |a_i| ≤ 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⋅10^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).
  
  Example
  
  Input
  
  
  3
  5 4
  6 3 4 2 1
  4 2
  1 -4 0 -2
  5 1
  1 2 3 4 5
  
  
  Output
  
  
  Yes
  No
  Yes
  
  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.
solution: 
  import java.io.*;
  import java.util.*;
  
  public class Solution {
  
      /* -------------------------------------- Main Start ----------------------------------- */
      public static void main(String[] args) throws IOException {
          FastReader fs = new FastReader();
          StringBuilder sb = new StringBuilder();
          int t = Integer.parseInt(fs.nextLine().trim());
          while (t-- > 0) {
              int n = fs.nextInt();
              int k = fs.nextInt();
              int[] arr = new int[n];
              int[] temp = new int[n];
              for (int i = 0; i < n; i++) {
                  arr[i] = fs.nextInt();
                  temp[i] = arr[i];
              }
              Arrays.sort(arr);
              HashMap<Integer, Integer> map = new HashMap<>();
              for (int i = 0; i < n; i++) {
                  map.put(arr[i], i);
              }
              ArrayList<ArrayList<Integer>> sum = new ArrayList<>();
              sum.add(new ArrayList<>());
              sum.get(0).add(temp[0]);
              int prev = temp[0];
              for (int i = 1; i < n; i++) {
                  if (prev < temp[i]) {
                      sum.get(sum.size() - 1).add(temp[i]);
                      prev = temp[i];
                  } else {
                      sum.add(new ArrayList<>());
                      sum.get(sum.size() - 1).add(temp[i]);
                      prev = temp[i];
                  }
              }
              int moves = sum.size();
              for (int i = 0; i < sum.size(); i++) {
                  if (sum.get(i).size() > 1) {
                      for (int j = 1; j < sum.get(i).size(); j++) {
                          int p = map.get(sum.get(i).get(j - 1));
                          int c = map.get(sum.get(i).get(j));
                          if (c - p != 1) {
                              moves++;
                          }
                      }
                  }
              }
              if (moves > k) {
                  System.out.println("NO");
              } else {
                  System.out.println("YES");
              }
  
          }
      }
  
      /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
    
        StringBuilder sb = new StringBuilder();
        sb.append(x + "\n");
      
        Collections.sort(arr, (a, b) -> Integer.compare(a[0], b[0]))
        arr.toArray(new int[arr.size()][])
      
       */
      private static final int MOD_1 = 1000000000 + 7;
  
      static class FastReader {
  
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() throws IOException {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
  
          String next() throws IOException {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          long nextLong() throws IOException {
              return Long.parseLong(next());
          }
  
          double nextDouble() throws IOException {
              return Double.parseDouble(next());
          }
  
          String nextLine() throws IOException {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
  
          /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
          void printArray(int[] arr) {
              System.out.println(Arrays.toString(arr));
          }
  
          void printArray(String[] arr) {
              System.out.println(Arrays.toString(arr));
          }
  
          void printArray(long[] arr) {
              System.out.println(Arrays.toString(arr));
          }
  
          void print(int data) {
              System.out.println(data);
          }
  
          void print(String data) {
              System.out.println(data);
          }
  
          void print(long data) {
              System.out.println(data);
          }
  
          int[] II(int n) throws IOException {
              int[] d = new int[n];
              String[] arr = nextLine().split(" ");
              for (int i = 0; i < n; i++) {
                  d[i] = Integer.parseInt(arr[i]);
              }
  
              return d;
          }
  
          String[] IS(int n) throws IOException {
              return nextLine().split(" ");
          }
  
          long[] IL(int n) throws IOException {
              long[] d = new long[n];
              String[] arr = nextLine().split(" ");
              for (int i = 0; i < n; i++) {
                  d[i] = Long.parseLong(arr[i]);
              }
              return d;
          }
  
          public long gcd(long a, long b) {
              if (a == 0) {
                  return b;
              }
              return gcd(b % a, a);
          }
  
          public long power(long x, long y, long p) {
              long res = 1;
              x = x % p;
              if (x == 0) {
                  return 0;
              }
  
              while (y > 0) {
                  if ((y & 1) == 1) {
                      res = (res * x) % p;
                  }
                  y = y >> 1;
                  x = (x * x) % p;
              }
              return res;
          }
  
          void sieveOfEratosthenes(boolean prime[], int size) {
              Arrays.fill(prime, true);
              prime[0] = prime[1] = false;
              prime[2] = true;
  
              for (int p = 2; p * p < size; p++) {
                  if (prime[p] == true) {
                      for (int i = p * p; i < size; i += p) {
                          prime[i] = false;
                      }
                  }
              }
          }
  
          public long fact(long n) {
              long ans = 1;
              for (int i = 2; i <= n; i++) {
                  ans = (ans * i) % MOD_1;
              }
              return ans;
          }
  
          public long lcm(long a, long b) {
              return (a * b) / gcd(a, b);
          }
  
          public int log2(int N) {
              int result = (int) (Math.log(N) / Math.log(2));
              return result;
          }
  
          // find first element in the arr that is equal to the x. 
          // If x is not present in arr then it will return first element that is greater than x
          // It return arr.size() if all element are smaller than x
          public int lowerBound(int[] arr, int x) {
              int low = 0, high = arr.length, mid = -1;
  
              while (low < high) {
                  mid = (low + high) / 2;
  
                  if (arr[mid] >= x) {
                      high = mid;
                  } else {
                      low = mid + 1;
                  }
              }
  
              return low;
          }
  
          // find first element in the arr that is greater than x. 
          // It return arr.size() if all element are smaller than x
          public int upperBound(int[] arr, int x) {
              int low = 0, high = arr.length, mid = -1;
  
              while (low < high) {
                  mid = (low + high) / 2;
  
                  if (arr[mid] > x) {
                      high = mid;
                  } else {
                      low = mid + 1;
                  }
              }
  
              return low;
          }
  
      }
  
  }
  