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.util.*;
  import java.io.*;
  public class Omar {
  	static Scanner sc=new Scanner(System.in);
  	static PrintWriter pw=new PrintWriter(System.out);
  
  	public static void main(String[] args) throws IOException,InterruptedException {
      int t=sc.nextInt();
      while(t-->0) {
      	int n=sc.nextInt(),k=sc.nextInt();
      	Integer [] a=new Integer[n];
      	HashMap<Integer, Integer> hm=new HashMap<>();
      	for(int i=0;i<n;i++) {
      		a[i]=sc.nextInt();
      	}
      	Integer [] b=a.clone();
      	Arrays.sort(b);
      	for(int i=0;i<n;i++) {
      		hm.put(b[i], i);
      	}
      	int ans=0;
      	for(int i=0;i<n;) {
      		int start=hm.get(a[i]);
      		while(i<n &&  start<n && a[i]==b[start]) {
                  start++;
      			i++;
      		}
      		ans++;
      	}
          if(ans>k)
          	pw.println("No");
          else 
          	pw.println("Yes");
      }
  		
  		
  		
  	pw.flush();
  	
  	}
  	
  	static class pair {
  		int x;
  		int y;
  		public pair(int a,int b) {
  			this.x=a;this.y=b;
  		}
  		public void swap(pair p) {
  			pair temp=new pair(p.x, p.y);
  			p.x=this.x;p.y=this.y;
  			this.x=temp.x;this.y=temp.y;
  		}
  		public String toString () {
  			return x+","+y+" ";
  		}
  		
  		public boolean equals(pair p) {
  			if(x==p.x && y==p.y)
  				return true;
  			return false;
  		}
  	}
  	/*static class PairPoint{
  		pair p1;
  		pair p2;
  		public PairPoint(pair p1,pair p2) {
  			this.p1=p1;
  			this.p2=p2;
  			
  		}
          public boolean inter(pair p) {
          	int x1=Math.max(p1.x, p2.x),x2=Math.min(p1.x, p2.x);
          	int y1=Math.max(p1.y, p2.y),y2=Math.min(p1.y, p2.y);
          	if((p.x>=x2 && p.x<=x1) && (p.y>=y2 && p.y<=y1))
          		return true;
          	return false;
   		}
  		public void swap(PairPoint pp) {
  			pp.p1.swap(this.p1);
  			pp.p2.swap(this.p2);
  		}
  		
  		public String toString () {
  			return p1.toString()+p2.toString();
  		}
  		public boolean equals (PairPoint pp) {
  			if(p1.equals(pp.p1) && p2.equals(pp.p2))
  				return true;
  			return false;
  		}
  		
  	}*/
  	static class Scanner {
  		StringTokenizer st;
  		BufferedReader br;
  		public Scanner(InputStream s) {
  			br = new BufferedReader(new InputStreamReader(s));
  		}
   
  		public Scanner(FileReader r) {
  			br = new BufferedReader(r);
  		}
   
  		public String next() throws IOException {
  			while (st == null || !st.hasMoreTokens())
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
  		public String readAllLines(BufferedReader reader) throws IOException {
  		    StringBuilder content = new StringBuilder();
  		    String line;
  		    
  		    while ((line = reader.readLine()) != null) {
  		        content.append(line);
  		        content.append(System.lineSeparator());
  		    }
   
  		    return content.toString();
  		}
  		public int nextInt() throws IOException {
  			return Integer.parseInt(next());
  		}
   
  		public long nextLong() throws IOException {
  			return Long.parseLong(next());
  		}
   
  		public String nextLine() throws IOException {
  			return br.readLine();
  		}
   
  		public double nextDouble() throws IOException {
  			String x = next();
  			StringBuilder sb = new StringBuilder("0");
  			double res = 0, f = 1;
  			boolean dec = false, neg = false;
  			int start = 0;
  			if (x.charAt(0) == '-') {
  				neg = true;
  				start++;
  			}
  			for (int i = start; i < x.length(); i++)
  				if (x.charAt(i) == '.') {
  					res = Long.parseLong(sb.toString());
  					sb = new StringBuilder("0");
  					dec = true;
  				} else {
  					sb.append(x.charAt(i));
  					if (dec)
  						f *= 10;
  				}
  			res += Long.parseLong(sb.toString()) / f;
  			return res * (neg ? -1 : 1);
  		}
   
  		public long[] nextlongArray(int n) throws IOException {
  			long[] a = new long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
   
  		public Long[] nextLongArray(int n) throws IOException {
  			Long[] a = new Long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
   
  		public int[] nextIntArray(int n) throws IOException {
  			int[] a = new int[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextInt();
  			return a;
  		}
   
  		public Integer[] nextIntegerArray(int n) throws IOException {
  			Integer[] a = new Integer[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextInt();
  			return a;
  		}
   
  		public boolean ready() throws IOException {
  			return br.ready();
  		}
   
  	}
   
  }