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:

Split the array into exactly $k$ non-empty subarrays such that each element belongs to exactly one subarray.

Reorder these subarrays arbitrary.

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).


-----Examples-----

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:

Split $a$ into $\{ [6], [3, 4], [2], [1] \}$.

Reorder them: $\{ [1], [2], [3,4], [6] \}$.

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.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Greedy algorithms


Solutions:
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	s = []
	d = {}
	for i in range(n):
		s.append(l[i])
		d[l[i]] = i
	s.sort()
	c = 1
	for i in range(0, n - 1):
		if d[s[i]] + 1 != d[s[i + 1]]:
			c += 1
	if c <= k:
		print('Yes')
	else:
		print('No')


from collections import defaultdict
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	lst = defaultdict(lambda : -1)
	cnt = 0
	for i in range(n):
		lst[arr[i]] = i
	arr.sort()
	x = lst[arr[0]]
	cnt = 1
	for i in range(1, n):
		y = lst[arr[i]]
		if y == x + 1:
			x = y
			continue
		cnt += 1
		x = y
	if cnt <= k:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	tmp = [0] * n
	for i in range(n):
		tmp[i] = arr[i]
	index = dict()
	tmp.sort()
	for i in range(n):
		index[tmp[i]] = i
	count = 0
	for i in range(n):
		if index[arr[i]] > 0 and i > 0 and (tmp[index[arr[i]] - 1] == arr[i - 1]):
			continue
		else:
			count += 1
	print('Yes' if count <= k else 'No')


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	dick = {}
	c = 0
	for ele in arr:
		dick[ele] = c
		c += 1
	count = 1
	sortarr = sorted(dick)
	for x in range(n - 1):
		if dick[sortarr[x]] + 1 != dick[sortarr[x + 1]]:
			count += 1
	if count > k:
		print('No')
	else:
		print('Yes')


import sys
for m in range(int(sys.stdin.readline())):
	n_k = list(map(int, sys.stdin.readline().strip().split(' ')))
	a = list(map(int, sys.stdin.readline().strip().split(' ')))
	n = n_k[0]
	k = n_k[1]
	b = a.copy()
	b.sort()
	hold = 0
	maximum = b[n - 1]
	Dict = {}
	counter = 0
	for elem in b:
		Dict[elem] = counter
		counter += 1
	for i in range(n - 1):
		number = a[i]
		nextnumber = a[i + 1]
		if nextnumber > number:
			if number != maximum:
				othernumber = b[Dict[number] + 1]
				if nextnumber == othernumber:
					hold += 1
	if n - hold <= k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	pos = {}
	for i in range(n):
		pos[b[i]] = i
	count = 1
	for i in range(1, n):
		if pos[a[i - 1]] + 1 == pos[a[i]]:
			continue
		else:
			count += 1
	if count <= k:
		print('Yes')
	else:
		print('No')


from sys import stdin
import bisect
for _ in range(int(stdin.readline())):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = sorted(a)
	cur = 1
	cur_idx = bisect.bisect_left(b, a[0])
	for i in range(1, n):
		if cur_idx + 1 == n or a[i] != b[cur_idx + 1]:
			cur += 1
			cur_idx = bisect.bisect_left(b, a[i])
			if cur > k:
				break
		else:
			cur_idx += 1
	if cur <= k:
		print('Yes')
	else:
		print('No')


t = int(input())
for tc in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	sorted_arr = sorted(arr)
	pos = {}
	for (i, x) in enumerate(sorted_arr):
		pos[x] = i
	cnt = 1
	for i in range(1, n):
		if pos[arr[i]] != pos[arr[i - 1]] + 1:
			cnt += 1
	if cnt <= k:
		print('Yes')
	else:
		print('No')


for ii in range(int(input())):
	(n, k) = map(int, input().split())
	ll = list(map(int, input().split()))
	ll_sorted = sorted(ll)
	d = {}
	for i in range(len(ll_sorted)):
		d[ll_sorted[i]] = i
	ans = n
	for i in range(n - 1):
		if d[ll[i]] == d[ll[i + 1]] - 1:
			ans -= 1
	if k >= ans:
		print('Yes')
	else:
		print('No')


import sys
import math
from collections import Counter
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	sorted_idx = {j: i for (i, j) in enumerate(b)}
	count = 0
	i = 0
	while i < n:
		j = sorted_idx[a[i]]
		while i < n and j < n and (a[i] == b[j]):
			i += 1
			j += 1
		count += 1
		if count > k:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	ls = list(map(int, input().split()))
	li = sorted(ls)
	memo = {li[i]: i for i in range(n)}
	x = 0
	i = 0
	while i < n:
		m = memo[ls[i]]
		j = 1
		while m + j < n and i + j < n:
			if ls[i + j] == li[m + j]:
				j += 1
			else:
				x += 1
				break
		if i + j == n or m + j == n:
			x += 1
		i = i + j
	if x <= k:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007
for _ in range(stdint()):
	(n, k) = stdmap()
	arr = stdarr()
	pair = []
	for i in range(n):
		pair.append([arr[i], i])
	pair.sort(key=lambda x: x[0])
	inds = []
	for i in pair:
		inds.append(i[1])
	split = [[inds[0]]]
	for i in range(1, len(inds)):
		if inds[i] - split[-1][-1] == 1:
			split[-1].append(inds[i])
		else:
			split.append([inds[i]])
	extra = 0
	for i in split:
		extra += len(i) - 1
	if len(split) > k:
		print('No')
	elif len(split) + extra >= k:
		print('Yes')
	else:
		print('No')


import os
import sys
from collections import Counter
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		l = list(map(int, input().split()))
		count = 1
		d = Counter()
		x = l.copy()
		x.sort()
		for i in range(n - 1):
			d[x[i]] = x[i + 1]
		d[x[n - 1]] = sys.maxsize
		for i in range(n - 1):
			if d[l[i]] != l[i + 1]:
				count += 1
		if count <= k:
			print('YES')
		else:
			print('NO')
main()


def solve():
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = sorted(A)
	D = dict()
	for i in range(n):
		D[B[i]] = i
	for i in range(n):
		A[i] = D[A[i]]
	cnt = 0
	pos = 0
	for i in range(n):
		if A[i] - A[pos] != i - pos:
			cnt += 1
			pos = i
		elif i != n - 1 and A[i] > A[i + 1]:
			cnt += 1
			pos = i + 1
	cnt += 1
	print('Yes' if cnt <= k else 'No')
for i in range(int(input())):
	solve()


from collections import deque as de
import math
from math import sqrt as sq
from math import floor as fl
from math import ceil as ce
from sys import stdin, stdout
import re
from collections import Counter as cnt
from functools import reduce
from itertools import groupby as gb
from bisect import bisect_left as bl, bisect_right as br

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

class graph:

	def __init__(self):
		self.graphdict = {}

	def add_edge(self, node, neighbor):
		if node not in self.graphdict:
			self.graphdict[node] = [neighbor]
		else:
			self.graphdict[node].append(neighbor)

	def show_edge(self):
		for node in self.graphdict:
			for neighbors in self.graphdict:
				print(node, neighbors)

	def show_graph(self):
		return self.graphdict

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def lcm(x, y):
	lcm = x * y // math.gcd(x, y)
	return lcm

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def checkisap(list):
	d = list[1] - list[0]
	for i in range(2, len(list)):
		temp = list[i] - list[i - 1]
		if temp != d:
			return False
	return True

def primes_method5(n):
	out = {}
	sieve = [True] * (n + 1)
	for p in range(2, n + 1):
		if sieve[p]:
			out[p] = 1
			for i in range(p, n + 1, p):
				sieve[i] = False
	return out

def getSum(n):
	strr = str(n)
	list_of_number = list(map(int, strr.strip()))
	return sum(list_of_number)

def checkperfectsquare(n):
	if ce(sq(n)) == fl(sq(n)):
		return True
	else:
		return False

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return list(map(str, input()))

def indict():
	dic = {}
	for (index, value) in enumerate(input().split()):
		dic[int(value)] = int(index) + 1
	return dic

def frqdict():
	dic = {}
	for (index, value) in enumerate(input()):
		if value not in dic:
			dic[value] = 1
		else:
			dic[value] += 1
	return dic
t = ii()
while t:
	t -= 1
	(n, k) = di()
	a = li()
	temp = sorted(a.copy())
	dic = {}
	for i in range(n):
		dic[a[i]] = i
	arraybreak = 0
	ind = None
	indele = None
	for i in range(n):
		if ind != None:
			if dic[temp[i]] - dic[indele] != i - ind:
				arraybreak += 1
				ind = i
				indele = temp[i]
		else:
			arraybreak += 1
			ind = i
			indele = temp[i]
	if arraybreak <= k:
		print('YES')
	else:
		print('NO')


from heapq import heappush

def solve():
	(n, k) = list(map(int, input().split(' ')))
	nums = [(int(x), i) for (i, x) in enumerate(input().split(' '))]
	cnt = 1
	nums.sort()
	for i in range(1, len(nums)):
		if nums[i][1] != nums[i - 1][1] + 1:
			cnt += 1
	print('Yes' if cnt <= k else 'No')
N = int(input())
for _ in range(N):
	solve()


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = enumerate([int(x) for x in input().split()])
	indices = [i[0] for i in sorted(a, key=lambda x: x[1])]
	recc = 0
	for i in range(n - 1):
		recc += indices[i + 1] != indices[i] + 1
	print('Yes' if recc + 1 <= k else 'No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a1 = sorted(a)
	mp = dict()
	for i in range(n - 1):
		mp[a1[i + 1]] = a1[i]
	mp[a1[0]] = 1000000000.0 + 2
	cur = 1
	for i in range(1, n):
		if mp[a[i]] != a[i - 1]:
			cur += 1
	if cur <= k:
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	t -= 1
	n_k = input().split()
	n = int(n_k[0])
	k = int(n_k[1])
	str_n = input().split()
	str_n = [int(str_n_i) for str_n_i in str_n]
	n_s = sorted(str_n)
	dicto = {}
	for i in range(n):
		dicto[n_s[i]] = i
	ans = 0
	if n == 1:
		print('Yes')
	else:
		for j in range(n - 1):
			if str_n[j] > str_n[j + 1]:
				ans += 1
			elif dicto[str_n[j]] + 1 != dicto[str_n[j + 1]]:
				ans += 1
		if ans + 1 > k:
			print('No')
		else:
			print('Yes')


import sys
input = sys.stdin.readline

def solve():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ref = list(arr)
	ref.sort()
	prev = {}
	for i in range(1, n):
		prev[ref[i]] = ref[i - 1]
	cnt = 1
	for i in range(1, n):
		if arr[i] not in prev:
			cnt += 1
			continue
		if arr[i - 1] == prev[arr[i]]:
			continue
		cnt += 1
	return 'Yes' if cnt <= k else 'No'
for _ in range(int(input())):
	print(solve())


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
seq_nll = lambda : list(map(int, input().strip()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
for _ in range(int(input())):
	(n, k) = input().split()
	ls = seq()
	n = int(n)
	k = int(k)
	cnt = 1
	a = sorted(ls)
	dic = dict()
	for i in range(n - 1):
		dic[a[i]] = a[i + 1]
	for i in range(1, n):
		if ls[i] < ls[i - 1] or dic[ls[i - 1]] != ls[i]:
			cnt += 1
	if k >= cnt:
		print('YES')
	else:
		print('NO')


for test in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(sorted(a))
	m = {}
	for i in range(n - 1):
		m[b[i]] = b[i + 1]
	m[b[-1]] = 10 ** 9 + 1
	c = 0
	i = 0
	if n == 1:
		c = 1
	else:
		while i < n:
			while m[a[i]] == a[i + 1]:
				i += 1
				if i == n - 1:
					break
			i += 1
			c += 1
			if i == n - 1:
				c += 1
				break
			elif i == n:
				break
	print('Yes' if c <= k else 'No')


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ind = {el: i for (i, el) in enumerate(sorted(a))}
	a = [ind[el] for el in a]
	res = 1
	for i in range(1, n):
		if a[i - 1] != a[i] - 1:
			res += 1
	if res > k:
		print('No')
	else:
		print('Yes')


t = int(input())
for tc in range(t):
	(n, k) = map(int, input().split())
	arr = [int(z) for z in input().split()]
	arr1 = sorted(arr)
	ind = {}
	for i in arr:
		ind[i] = [0, 0]
	for i in range(n):
		ind[arr1[i]][0] = i
		ind[arr[i]][1] = i
	k1 = 1
	for i in range(1, n):
		if ind[arr[i]][0] == ind[arr[i - 1]][0] + 1:
			continue
		else:
			k1 += 1
	if k1 <= k:
		print('Yes')
	else:
		print('No')


import bisect

def canBeFormed(n, arr, k):
	sortedArr = sorted(arr)
	found = None
	kVal = 0
	for i in range(n):
		if found is not None:
			if found + 1 < n and sortedArr[found + 1] == arr[i]:
				found += 1
			else:
				found = bisect.bisect_left(sortedArr, arr[i])
				kVal += 1
		else:
			found = bisect.bisect_left(sortedArr, arr[i])
			kVal += 1
	if kVal <= k:
		return True
	return False
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if canBeFormed(n, arr, k):
		print('Yes')
	else:
		print('No')


t = int(input())
for t_ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	sortedarr = sorted(arr)
	tmp = {sortedarr[i]: sortedarr[i + 1] for i in range(n - 1)}
	res = 1
	for (i, v) in enumerate(arr[:-1]):
		if arr[i + 1] != tmp.get(v, None):
			res += 1
	print('YES' if res <= k else 'NO')


def func(n, k, arr):
	if k == n:
		return 'Yes'
	indarr = [[el, i] for (i, el) in enumerate(arr)]
	indarr.sort()
	count = 1
	for i in range(n - 1):
		if indarr[i][1] != indarr[i + 1][1] - 1:
			count += 1
	if count <= k:
		return 'Yes'
	else:
		return 'No'

def main():
	loop = int(input())
	na = []
	arrs = []
	ka = []
	for _ in range(loop):
		(n, k) = list(map(int, input().split()))
		arrs.append(list(map(int, input().split())))
		na.append(n)
		ka.append(k)
	for i in range(loop):
		print(func(na[i], ka[i], arrs[i]))
main()


t = int(input())
while t:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	c = 0
	d = {}
	ans = arr.copy()
	ans.sort()
	arr = [-float('inf')] + arr + [float('inf')]
	ans = [float('inf')] + ans + [-float('inf')]
	for i in range(len(arr)):
		d[arr[i]] = i
	i = 1
	while i <= n:
		j = d[ans[i]]
		if arr[j + 1] == ans[i + 1]:
			pass
		else:
			c += 1
		i += 1
	if k >= c:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))[:n]
	dict = {}
	std = sorted(arr)
	for i in range(n):
		dict[std[i]] = i
	c = 0
	for i in range(n - 1):
		if arr[i] > arr[i + 1]:
			c += 1
		else:
			a = dict[arr[i]]
			b = dict[arr[i + 1]]
			if b - a != 1:
				c += 1
	c += 1
	if c <= k:
		print('Yes')
	else:
		print('No')


for q_ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = {arr[i]: i for i in range(n)}
	arr.sort()
	r = 1
	for i in range(1, n):
		if d[arr[i]] - d[arr[i - 1]] != 1:
			r += 1
	print('Yes' if r <= k else 'No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	tmp = []
	for i in range(n):
		tmp.append(a[i])
	tmp.sort()
	d = {}
	x = 1
	for i in range(n):
		d[tmp[i]] = x
		x += 1
	for i in range(n):
		a[i] = d[a[i]]
	seg = 0
	a.append(-1)
	for i in range(1, n + 1):
		if a[i] - a[i - 1] == 1:
			continue
		else:
			seg += 1
	if seg <= k:
		print('YES')
	else:
		print('NO')


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	a = map(int, input().split())
	a = list(a)
	mp = {}
	for i in range(n):
		mp[a[i]] = i
	ans = 1
	a.sort()
	for i in range(1, n):
		if mp[a[i]] != mp[a[i - 1]] + 1:
			ans = ans + 1
	if ans <= k:
		print('Yes')
	else:
		print('No')


from collections import defaultdict as dd, Counter as C

def func(n, vec, k):
	vecb = sorted(vec)
	next = {}
	for i in range(n - 1):
		next[vecb[i]] = vecb[i + 1]
	next[vecb[-1]] = 10 ** 10
	len = 1
	for i in range(1, n):
		if next[vec[i - 1]] != vec[i]:
			len += 1
	return k >= len
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	vec = list(map(int, input().split()))
	answer = func(n, vec, k)
	if answer:
		print('Yes')
	else:
		print('No')


def solve():
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	b = [a for a in arr]
	b.sort()
	b = dict(zip(b, range(n)))
	non_decreasing_subarrays = 1
	for i in range(1, n):
		if b.get(arr[i]) == 1 + b.get(arr[i - 1]):
			continue
		non_decreasing_subarrays += 1
	if non_decreasing_subarrays <= k:
		return 'Yes'
	return 'No'
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n != k:
		l = sorted(list(a))
		d = {}
		for i in range(n):
			d[l[i]] = i
		b = 0
		for i in range(n - 1):
			if d[a[i]] != d[a[i + 1]] - 1:
				b += 1
		b += 1
		print('Yes' if b <= k else 'No')
	else:
		print('Yes')


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations, accumulate, zip_longest, combinations_with_replacement
from math import gcd, floor, inf, log2, sqrt, log10, factorial
from bisect import bisect_right, bisect_left
from statistics import mode
from string import ascii_lowercase, ascii_uppercase
cases = int(input())
for _ in range(cases):
	(ln, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	inds = {n: i for (i, n) in enumerate(arr)}
	sor = sorted(arr)
	cut = 1
	for (i, n) in enumerate(sor[:-1]):
		nxt = sor[i + 1]
		ind = inds[n]
		if ind == ln - 1 or inds[nxt] - ind != 1:
			cut += 1
	if cut > k:
		print('No')
	else:
		print('Yes')


from collections import defaultdict

def findAns(arr, n, k):
	d = defaultdict(lambda : -1)
	lst = list(sorted(arr))
	for i in range(len(lst)):
		d[lst[i]] = i
	res = 1
	for i in range(1, len(arr)):
		if d[arr[i]] - d[arr[i - 1]] != 1:
			res += 1
	if res > k:
		return 'No'
	return 'Yes'
T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	print(findAns(arr, n, k))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	nextNum = {}
	aSorted = sorted(a)
	for i in range(n - 1):
		nextNum[aSorted[i]] = aSorted[i + 1]
	nextNum[aSorted[n - 1]] = aSorted[n - 1] + 1
	count = 1
	for i in range(n - 1):
		if nextNum[a[i]] != a[i + 1]:
			count += 1
	if count <= k:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	[n, k] = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	s = sorted([i for i in range(n)], key=lambda x: a[x])
	ans = 1
	for i in range(1, n):
		if s[i - 1] + 1 == s[i]:
			continue
		else:
			ans += 1
	if ans > k:
		print('No')
	else:
		print('Yes')


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
INT_MAX = 10 ** 13
from bisect import bisect_left
import sys
MOD = 10 ** 9 + 7
inf = MOD ** 2
from decimal import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = INPUT()
	B = A.copy()
	B.sort()
	D = {}
	for i in range(n):
		D[A[i]] = i
	count = 1
	for i in range(1, n):
		if D[B[i]] - D[B[i - 1]] != 1:
			count += 1
	if count <= k:
		print('Yes')
	else:
		print('No')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from bisect import bisect_left as lower_bound, bisect_right as upper_bound

def so():
	return int(input())

def st():
	return input()

def mj():
	return map(int, input().strip().split(' '))

def msj():
	return map(str, input().strip().split(' '))

def le():
	return list(map(int, input().split()))

def lebe():
	return list(map(int, input()))

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()

def joro(L):
	return ''.join(map(str, L))

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def tr(n):
	return n * (n + 1) // 2

def ma(m):
	import math as my
	y = my.floor(my.log(m, 2))
	if y % 2 != 0:
		return y
	return y - 1

def iu():
	import sys
	import math as my
	(n, q) = mj()
	L = le()
	d = []
	c = 0
	for i in range(n):
		d.append([L[i], i])
	d.sort()
	ut = 1
	for ut in range(1, n, 1):
		if d[ut][1] == 1 + d[ut - 1][1]:
			continue
		c = 1 + c
		ut += 1
	if c + 1 <= q:
		print('Yes')
	else:
		print('No')

def main():
	for i in range(so()):
		iu()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[i] = l[i]
	d1 = dict(sorted(d.items(), key=lambda item: item[1]))
	a = 1
	l2 = list(d1.keys())
	for i in range(1, n):
		if l2[i - 1] + 1 != l2[i]:
			a += 1
	if a <= k:
		print('Yes')
	else:
		print('No')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd
for t in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = sorted(l)
	d = dd(int)
	for i in range(n):
		d[l1[i]] = i
	i = 0
	while i < n - 1:
		if d[l[i]] - d[l[i + 1]] == -1:
			while d[l[i]] - d[l[i + 1]] == -1:
				i += 1
				if i == n - 1:
					break
			if i < n - 1:
				k -= 1
		else:
			k -= 1
		i += 1
	if k >= 1:
		print('Yes')
	else:
		print('No')


import random
from collections import Counter as cc
from copy import deepcopy as dc
import math
try:
	t = int(input())
	for tt in range(1, t + 1):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		(s, i) = ([], 0)
		b = sorted(a)
		d = {}
		for i in range(n):
			d[b[i]] = i
		i = 0
		while i < n:
			(tp, tmp) = (i, [a[i]])
			for j in range(i + 1, n):
				if d[a[tp]] == d[a[j]] - 1:
					tmp.append(a[j])
					tp = j
				else:
					break
			s.append(tmp)
			i = tp + 1
		s = sorted(s)
		if len(s) > k:
			print('No')
		else:
			x = []
			for i in s:
				x += i
			if x == b:
				print('Yes')
			else:
				print('No')
except EOFError as e:
	pass


def solve():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = sorted(arr)
	positions = {}
	count = 1
	for i in range(n):
		positions[brr[i]] = i
	for i in range(n - 1):
		if positions[arr[i]] + 1 != positions[arr[i + 1]]:
			count += 1
	if k >= count:
		print('Yes')
	else:
		print('No')
t = int(input())
for i in range(t):
	solve()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	e = []
	for j in range(n):
		d = []
		d.append(a[j])
		d.append(j)
		e.append(d)
	e.sort()
	d = 0
	for j in range(1, n):
		if e[j - 1][1] + 1 != e[j][1]:
			d = d + 1
	if d < k:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k > n:
		print('No')
	elif k == n:
		print('Yes')
	else:
		b = arr[:]
		b.sort()
		d = {}
		for i in range(len(b) - 1):
			d[b[i]] = b[i + 1]
		count = 1
		for i in range(n - 1):
			if arr[i] not in d:
				count += 1
			elif d[arr[i]] != arr[i + 1]:
				count += 1
		if count <= k:
			print('Yes')
		else:
			print('No')


import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	(number, bounValue) = map(int, input().strip().split(' '))
	initialArray = list(map(int, input().strip().split(' ')))
	newArray = []
	for i in range(len(initialArray)):
		newArray.append([initialArray[i], i])
	newArray.sort()
	totalCount = 1
	for i in range(len(initialArray) - 1):
		if newArray[i + 1][1] != newArray[i][1] + 1:
			totalCount += 1
	if totalCount <= bounValue:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	l = []
	(x, y) = map(int, input().split(' '))
	m = list(map(int, input().split(' ')))
	for j in range(len(m)):
		l.append([m[j], j])
	l.sort()
	ans = 1
	for j in range(len(m) - 1):
		if l[j][1] + 1 != l[j + 1][1]:
			ans = ans + 1
	if ans > y:
		print('No')
	else:
		print('Yes')


import sys
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	alst = list(map(int, input().split()))
	se = set(alst)
	lst = sorted(se)
	dic = {}
	for (i, a) in enumerate(lst):
		dic[a] = i
	alst = [dic[a] for a in alst]
	bef = -10
	cnt = 0
	for a in alst:
		if bef + 1 != a:
			cnt += 1
		bef = a
	if cnt <= k:
		print('Yes')
	else:
		print('No')
for _ in range(int(input())):
	main()


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	final = {}
	for (i, e) in enumerate(sorted(a)):
		final[e] = i
	cut = 0
	for i in range(len(a) - 1):
		if final[a[i + 1]] - final[a[i]] != 1:
			cut += 1
	print('Yes' if cut + 1 <= k else 'No')


t = int(input())
while t:
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	z = list(l)
	z.sort()
	d = {}
	for i in range(n):
		d[z[i]] = i + 1
	temp = 0
	if n == 1:
		print('YES')
	else:
		i = 0
		e = {}
		for i in range(n - 1):
			w = d[l[i + 1]] - d[l[i]]
			if w != 1:
				c += 1
		if c + 1 <= k:
			print('YES')
		else:
			print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ind = {}
	x = sorted(a)
	for i in range(n):
		ind[x[i]] = i
	c = 1
	for i in range(n - 1):
		if ind[a[i]] != ind[a[i + 1]] - 1:
			c = c + 1
	if c > k:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n < k:
		print('No')
	elif n == k:
		print('Yes')
	else:
		b = a[:]
		b.sort()
		d = {}
		for i in range(n - 1):
			d[b[i]] = b[i + 1]
		cnt = 1
		for i in range(n - 1):
			if a[i] not in d:
				cnt += 1
			elif d[a[i]] != a[i + 1]:
				cnt += 1
		if cnt > k:
			print('No')
		else:
			print('Yes')


from bisect import *

def index(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return -1
t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = a[:]
	b.sort()
	groups = 1
	for i in range(n - 1):
		j = index(b, a[i])
		if j == n - 1 or a[i + 1] != b[j + 1]:
			groups += 1
	if groups > k:
		print('No')
	else:
		print('Yes')


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = {a[i]: a[i + 1] for i in range(n - 1)}
	b[a[n - 1]] = 10 ** 6
	c = sorted(a)
	g = 1
	for i in range(n - 1):
		if b[c[i]] != c[i + 1]:
			g += 1
	if g > k:
		print('No')
	else:
		print('Yes')


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 10 ** 16
md = 10 ** 9 + 7

def solve():
	(n, k) = map(int, sys.stdin.readline().split())
	l = LI()
	count = n
	x = l[0]
	d = {}
	for i in range(n - 1):
		d[l[i]] = l[i + 1]
	d[l[n - 1]] = None
	p = sorted(l)
	for i in range(n - 1):
		if p[i + 1] == d[p[i]]:
			count += -1
	if k >= count:
		print('Yes')
	else:
		print('No')
for testcase in range(II()):
	solve()


t = int(input())
for i in range(t):
	[n, k] = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = a.copy()
	b.sort()

	def binSearch(ele):
		start = 0
		end = n - 1
		while start <= end:
			mid = (start + end) // 2
			if b[mid] == ele:
				return mid
			elif b[mid] < ele:
				start = mid + 1
			else:
				end = mid - 1

	def consec(h, k):
		s = binSearch(h)
		if b[s + 1] == k:
			return True
		else:
			return False
	cnt = 1
	prev = a[0]
	for i in range(1, n):
		if a[i] < prev:
			cnt += 1
		elif not consec(prev, a[i]):
			cnt += 1
		prev = a[i]
	if cnt > k:
		print('NO')
	else:
		print('YES')


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
from itertools import permutations
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split(' ')))

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

def get_str():
	return input().strip()

def get_strs():
	return get_str().split(' ')

def flat_list(arr):
	return [item for subarr in arr for item in subarr]

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def solve_a():
	n = get_int()
	a = get_ints()
	return max(a) + (sum(a) - max(a)) / (n - 1)

def solve_b():
	(n, k) = get_ints()
	a = get_ints()
	a_e = [(x, i) for (i, x) in enumerate(a)]
	a_e.sort()
	c = [-float('inf')] + [i for (x, i) in a_e]
	cnt = 0
	for i in range(1, n + 1):
		if c[i] != c[i - 1] + 1:
			cnt += 1
	return yes_no(cnt <= k).title()
t = get_int()
for _ in range(t):
	print(solve_b())


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = ''
	temp = sorted(([arr[i], i] for i in range(n)))
	if arr == sorted(arr):
		res = 'Yes'
	count = 1
	for i in range(1, n):
		if temp[i][1] != temp[i - 1][1] + 1:
			count += 1
	if count <= k:
		res = 'Yes'
	else:
		res = 'No'
	print(res)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_list_strings():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve(n, k, arr):
	temp = []
	final = []
	sortedArray = arr[:]
	sortedArray.sort()
	store = {}
	for i in range(n - 1):
		store[sortedArray[i]] = sortedArray[i + 1]
	store[sortedArray[-1]] = float('inf')
	temp = [arr[0]]
	current = arr[0]
	count = 0
	for i in range(1, n):
		if store[current] == arr[i]:
			temp.append(arr[i])
			current = arr[i]
		else:
			if len(temp) != 0:
				count += 1
			temp = [arr[i]]
			current = arr[i]
	if len(temp) != 0:
		count += 1
	if count <= k:
		sys.stdout.write(str('YES') + '\n')
	else:
		sys.stdout.write(str('NO') + '\n')
T = get_int()
while T:
	(n, k) = get_ints()
	arr = get_list()
	solve(n, k, arr)
	T -= 1


for t in range(int(input())):
	(n, k) = [int(k) for k in input().split()]
	a = [int(k) for k in input().split()]
	if n == 1:
		print('Yes')
		continue
	sa = sorted(a)
	dic = {}
	for i in range(n):
		dic[sa[i]] = i
	i = 0
	k -= 1
	while k >= 0 and i < n - 1:
		if dic[a[i + 1]] != dic[a[i]] + 1:
			k -= 1
		i += 1
	if k >= 0 and i == n - 1:
		print('Yes')
	else:
		print('No')


def binarySearch(l1, low, high, x):
	index = -1
	while low <= high:
		mid = (low + high) // 2
		if l1[mid] == x:
			return mid
		elif l1[mid] > x:
			high = mid - 1
		else:
			low = mid + 1
	return index

def res(n, l, k):
	l1 = sorted(l)
	i = 0
	count = 0
	while i < n:
		index = binarySearch(l1, 0, n - 1, l[i])
		while index < n and i < n:
			if l1[index] == l[i]:
				index += 1
				i += 1
			else:
				break
		count += 1
	if count <= k and k <= n:
		return 1
	return 0
for t in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if res(n, l, k) == 1:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	line1 = [int(x) for x in input().split()]
	(n, k) = (line1[0], line1[1])
	arr = [int(x) for x in input().split()]
	ans_arr = [i[0] for i in sorted(enumerate(arr), key=lambda x: x[1])]
	flag = 1
	prev = ans_arr[0]
	for i in range(1, n):
		if ans_arr[i] - prev != 1:
			k -= 1
			if k <= 0:
				flag = 0
				break
		prev = ans_arr[i]
	if flag == 1:
		print('Yes')
	else:
		print('No')


def func(x):
	i = 0
	j = n - 1
	while i <= j:
		mid = (i + j) // 2
		if a[mid] == x:
			return mid
		elif a[mid] < x:
			i = mid + 1
		else:
			j = mid - 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	a = []
	for i in l:
		a.append(i)
	a.sort()
	ans = 1
	for i in range(1, n):
		temp = func(l[i])
		if temp != 0 and a[temp - 1] == l[i - 1]:
			continue
		else:
			ans += 1
	if ans <= k:
		print('YES')
	else:
		print('NO')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	sortedarr = sorted(arr)
	indexes = {}
	for i in range(n):
		indexes[sortedarr[i]] = i
	real = []
	groups = n
	for i in range(n):
		real.append(indexes[arr[i]])
		if len(real) > 1 and real[-1] - real[-2] == 1:
			groups -= 1
	if groups <= k:
		print('Yes')
	else:
		print('No')
T = int(input())
t = 1
while t <= T:
	main(t)
	t += 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	di = {}
	a = 1
	for i in sorted(li):
		di[i] = a
		a += 1
	changes = 0
	i = 0
	while i < n - 1:
		while i < n - 1 and di[li[i + 1]] - di[li[i]] == 1:
			i += 1
		if i != n - 1:
			changes += 1
		i += 1
	if changes < k:
		print('Yes')
	else:
		print('No')


from collections import defaultdict
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	splat = 0
	d = defaultdict(int)
	lis = sorted(arr)
	for i in range(1, n):
		d[lis[i - 1], lis[i]] += 1
	for i in range(1, n):
		if d[arr[i - 1], arr[i]]:
			d[arr[i - 1], arr[i]] -= 1
		else:
			splat += 1
	splat += 1
	if splat <= k:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = {}
	for j in range(n):
		b[a[j]] = j
	c = sorted(b)
	ans = 1
	for j in range(n - 1):
		if b[c[j]] + 1 != b[c[j + 1]]:
			ans += 1
	if ans <= k:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k2 = 0
	for i in range(n - 1):
		if a[i] < a[i + 1]:
			for j in a:
				if a[i] < j < a[i + 1]:
					k2 += 1
					break
		else:
			k2 += 1
	if k2 + 1 <= k:
		print('Yes')
	else:
		print('No')


for t in range(int(input())):
	(n, k) = map(int, input().split())
	(*a,) = map(int, input().split())
	sorted_a = sorted(a)
	d = {}
	for i in range(n):
		d[sorted_a[i]] = i
	print('YNeos'[1 + sum(map(lambda i: d[a[i]] != d[a[i - 1]] + 1, range(1, n))) > k::2])


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	li = []
	for i in range(n):
		li.append([a[i], i])
	li.sort()
	b = sorted(a)
	c = 0
	if n == 1:
		print('Yes')
	elif a == b:
		print('Yes')
	else:
		c = 1
		for i in range(1, n):
			if li[i][1] - i != li[i - 1][1] - (i - 1):
				c += 1
		if c <= k:
			print('Yes')
		else:
			print('No')


def mohamed(a, k):
	aux = [int(i) for i in input().split()]
	aux2 = sorted(aux)
	pairs = {}
	for i in range(a - 1):
		pairs[aux2[i]] = aux2[i + 1]
	consecuent = 1
	for i in range(a - 1):
		if pairs.get(aux[i]) != aux[i + 1]:
			consecuent += 1
	if consecuent > k:
		print('NO')
	else:
		print('YES')
n = input()
for i in range(int(n)):
	variables = input().split()
	a = int(variables[0])
	k = int(variables[1])
	mohamed(a, k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	sorted_l = sorted(l)
	index = sorted(range(len(l)), key=l.__getitem__)
	num_group = n
	for i in range(n - 1):
		if index[i] + 1 == index[i + 1]:
			num_group -= 1
	if num_group <= k:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	reference = sorted(arr)
	reference_graph = {}
	for (i, x) in enumerate(reference):
		if i != n - 1:
			reference_graph[x] = set([reference[i + 1]])
		else:
			reference_graph[x] = set([x + 1])
	cnt = 1
	prev = arr[0]
	for i in range(1, len(arr)):
		x = arr[i]
		if x not in reference_graph[prev]:
			cnt += 1
		prev = arr[i]
	if cnt <= k:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	d = dict()
	for i in range(n):
		d[b[i]] = i
	for i in range(n):
		a[i] = d[a[i]]
	cnt = 1
	for i in range(1, n):
		if a[i - 1] + 1 != a[i]:
			cnt += 1
	print('YES' if cnt <= k else 'NO')


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
tests = int(input())
for test in range(tests):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = sorted([(a[i], i) for i in range(n)])
	s = 1
	for i in range(1, n):
		if b[i][1] != b[i - 1][1] + 1:
			s += 1
	if k >= s:
		print('Yes')
	else:
		print('No')


from collections import defaultdict as df
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = 0
	b = []
	for i in range(n):
		b.append([a[i], i])
	b.sort()
	for i in range(1, n):
		if b[i][1] - b[i - 1][1] != 1:
			cnt += 1
	if cnt >= k:
		print('No')
	else:
		print('Yes')


from sys import stdin as sin

def aint():
	return int(input())

def amap():
	return map(int, sin.readline().split())

def alist():
	return list(map(int, sin.readline().split()))

def astr():
	return input()
for _ in range(aint()):
	(n, k) = amap()
	l = alist()
	d = {}
	for i in range(n):
		d[l[i]] = i
	l.sort()
	p = 0
	last = -10
	for i in range(n):
		if d[l[i]] != last + 1:
			p += 1
		last = d[l[i]]
	if p > k:
		print('No')
	else:
		print('Yes')


import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(iinp()):
	(n, k) = mp()
	arr = lmp()
	sarr = sorted(arr)
	inds = {}
	for i in range(n):
		inds[sarr[i]] = i
	x = 1
	for i in range(1, n):
		if inds[arr[i]] != inds[arr[i - 1]] + 1:
			x += 1
	print('Yes' if k >= x else 'No')


import sys
try:
	sys.stdin = open('inputf.in', 'r')
	sys.stdout = open('outputf.in', 'w')
except:
	pass
import math
from math import sqrt
from collections import defaultdict
from collections import Counter
import string
from collections import deque
from functools import cmp_to_key
import bisect
from collections import OrderedDict
import heapq as hq
from queue import PriorityQueue
MOD = 10 ** 9 + 7

def ii():
	return int(sys.stdin.readline().strip())

def si():
	return sys.stdin.readline().strip()

def li():
	return list(map(int, sys.stdin.readline().strip().split()))

def lsi():
	return list(map(str, sys.stdin.readline().strip().split()))

def mi():
	return map(int, sys.stdin.readline().strip().split())

def dparr(m, n):
	return [[0] * n for i in range(m)]
t = ii()
for _ in range(t):
	(n, k) = mi()
	arr = li()
	rind = {}
	for i in range(n):
		rind[arr[i]] = i
	req = 1
	arr.sort()
	for i in range(n):
		if i == 0:
			continue
		elif rind[arr[i]] - 1 != rind[arr[i - 1]]:
			req += 1
		else:
			continue
	if req > k:
		print('NO')
	elif req <= k:
		print('YES')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	a = [i[0] for i in sorted(enumerate(lst), key=lambda x: x[1])]
	cnt = 0
	for i in range(n - 1):
		if a[i] != a[i + 1] - 1:
			cnt += 1
	if cnt + 1 > k:
		print('No')
	else:
		print('Yes')


import math
import sys
import queue

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	f = {b[i]: b[i + 1] for i in range(n - 1)}
	r = 1
	for i in range(1, n):
		if a[i - 1] not in f:
			r += 1
		elif a[i] != f[a[i - 1]]:
			r += 1
	if r <= k:
		print('Yes')
	else:
		print('No')
multi_test = 1
if multi_test:
	t = int(input())
	for _ in range(t):
		solve()
else:
	solve()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	a = sorted(arr)
	dici = {}
	for i in range(len(a) - 1):
		dici[a[i]] = a[i + 1]
	bp = 0
	for i in range(len(arr) - 1):
		if arr[i] != a[-1] and dici[arr[i]] != arr[i + 1]:
			bp += 1
	if a[-1] != arr[-1]:
		bp += 1
	if k >= bp + 1:
		print('YES')
	else:
		print('NO')


for sfsdfgsd in range(int(input())):
	a = 0
	(zfdvgfsd, fgsfsf) = map(int, input().split())
	a += 1
	a += 1
	a += 1
	sgsfgsfg = list(map(int, input().split()))
	a += 1
	sdgsgsete = sorted(sgsfgsfg)
	d = {}
	j = 0
	a += 1
	for i in sdgsgsete:
		d[i] = j
		j += 1
	c = 0
	a += 1
	for i in range(zfdvgfsd - 1):
		x = d[sgsfgsfg[i]]
		a += 1
		if x == zfdvgfsd - 1:
			c += 1
		elif sdgsgsete[x + 1] != sgsfgsfg[i + 1]:
			c += 1
	a += 1
	a += 1
	if c + 1 <= fgsfsf:
		print('YES')
	else:
		print('NO')
	a += 1
	a += 1
	a += 1
	a += 1


def main():
	import sys
	input = sys.stdin.readline
	sys.setrecursionlimit(10 ** 7)
	from collections import Counter, deque
	from collections import defaultdict
	from itertools import combinations, permutations, accumulate, groupby, product
	from bisect import bisect_left, bisect_right
	from heapq import heapify, heappop, heappush
	from math import floor, radians, ceil, pi, factorial, gcd, atan, degrees, sqrt, cos, sin
	from operator import itemgetter

	def I():
		return int(input())

	def MI():
		return map(int, input().split())

	def LI():
		return list(map(int, input().split()))

	def SI():
		return input().rstrip()

	def printns(x):
		print('\n'.join(x))

	def printni(x):
		print('\n'.join(list(map(str, x))))
	inf = 10 ** 17
	mod = 10 ** 9 + 7
	mod2 = 998244353
	t = I()
	for i in range(t):
		(n, k) = MI()
		lis = LI()
		nlis = sorted(lis)
		dic = {}
		for i in range(n):
			dic[nlis[i]] = i
		comp = []
		for i in range(n):
			comp.append(dic[lis[i]])
		spl = 1
		for i in range(n - 1):
			if comp[i] + 1 != comp[i + 1]:
				spl += 1
		if spl > k:
			print('No')
		else:
			print('Yes')
main()


from math import *
from collections import defaultdict as dt
from sys import stdin
inp = lambda : stdin.readline().strip()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
L = lambda : list(M())
mod = 1000000007
inf = 100000000000000000000
ss = 'abcdefghijklmnopqrstuvwxyz'

def solve():
	(n, k) = M()
	a = L()
	b = sorted(a)
	d = dt(int)
	c = 0
	for i in range(n):
		d[a[i]] = i
	for i in range(1, n):
		if d[b[i]] - d[b[i - 1]] != 1:
			c = c + 1
	if c < k:
		print('Yes')
	else:
		print('No')
tt = 1
tt = I()
for _ in range(tt):
	solve()


def moamen(n, k, array):
	sortedArray = sorted(array)
	subarrays = 0
	pairs = {}
	for i in range(n - 1):
		pairs[sortedArray[i]] = sortedArray[i + 1]
	for i in range(n):
		if i == n - 1:
			subarrays += 1
			break
		if pairs.get(array[i]) != array[i + 1]:
			subarrays += 1
	if subarrays > k:
		return 'NO'
	else:
		return 'YES'
n = input()
for i in range(int(n)):
	variables = input().split()
	n = int(variables[0])
	k = int(variables[1])
	array = input().split()
	array = [int(i) for i in array]
	print(moamen(n, k, array))


def solve():
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	arr2 = sorted(arr.copy())
	gdzie = dict()
	for i in range(n):
		gdzie[arr2[i]] = i
	ile = 1
	for i in range(1, n):
		if gdzie[arr[i]] - gdzie[arr[i - 1]] == 1:
			pass
		else:
			ile += 1
	if ile <= k:
		print('Yes')
	else:
		print('No')

def main():
	for i in range(int(input())):
		solve()
main()


import bisect
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = sorted(a)
	m = 1
	for i in range(1, n):
		if a[i] < a[i - 1]:
			m += 1
		elif a[i] > a[i - 1]:
			k1 = bisect.bisect_right(b, a[i - 1]) - 1
			if b[k1 + 1] != a[i]:
				m += 1
	print('Yes' if m <= k else 'No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = sorted(arr)
	indexes = {s[i]: i for i in range(n)}
	prev = -2
	ans = 0
	for i in range(n):
		cur = indexes[arr[i]]
		if cur == prev + 1:
			pass
		else:
			ans += 1
		prev = cur
	if ans <= k:
		print('Yes')
	else:
		print('No')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_right, bisect_left

def index(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	raise ValueError

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_le(a, x):
	i = bisect_right(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def find_ge(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def intArr():
	return map(int, input().split())

def In():
	return int(input())

def func():
	(n, k) = intArr()
	arr = list(intArr())
	if k == n:
		return 'Yes'
	m = 1
	i = 0
	temp = sorted(arr)
	while i < n:
		idx = index(temp, arr[i])
		while (idx < n and i < n) and temp[idx] == arr[i]:
			i += 1
			idx += 1
		if i >= n:
			break
		m += 1
	if m > k:
		return 'No'
	return 'Yes'

def main():
	for _ in range(In()):
		print(func())
	return
main()


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def get_list():
	return [int(i) for i in input().split()]

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	m = [[l[i], i] for i in range(n)]
	m.sort()
	counter = 0
	for i in range(1, n):
		if m[i][1] - m[i - 1][1] > 1:
			counter += 1
		elif m[i][1] - m[i - 1][1] < 0:
			counter += 1
	yn(counter + 1 <= k)


import sys
input = sys.stdin.buffer.readline

def process(A, k):
	n = len(A)
	A2 = sorted(A)
	next_dict = {}
	for i in range(n - 1):
		next_dict[A2[i]] = A2[i + 1]
	answer = 0
	for i in range(n - 1):
		if A[i] in next_dict and A[i + 1] != next_dict[A[i]]:
			answer += 1
		elif A[i] == A2[-1] and i != n - 1:
			answer += 1
		if answer > k - 1:
			return 'No'
	return 'Yes'
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	print(process(A, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	listedon = list(map(int, input().split()))
	tupples = []
	plusun = 1
	kk = 1
	for elmt in listedon:
		tupples.append((elmt, plusun))
		plusun += 1
	tupples.sort()
	last = tupples[0][1]
	for (elmt, elmtt) in tupples[1:]:
		if elmtt == last + 1:
			last = elmtt
			continue
		else:
			kk += 1
			last = elmtt
	if kk > k:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == k:
		print('Yes')
		continue
	if n == 2 and k == 1:
		if a[0] > a[1]:
			print('No')
		else:
			print('Yes')
		continue
	if k == 1:
		print('Yes') if a == sorted(a) else print('No')
		continue
	if k >= 2:
		b = sorted(a)
		d = {}
		for i in range(n - 1):
			d[b[i]] = b[i + 1]
		d[b[n - 1]] = 10 ** 10
		count = 0
		for i in range(n - 1):
			if d[a[i]] != a[i + 1]:
				count += 1
		print('No') if count + 1 > k else print('Yes')


tests = int(input())
for x in range(0, tests):
	(length, k) = list(map(int, input().split()))
	if k > length:
		print('NO')
		continue
	nums_str = input()
	nums = list(map(int, nums_str.split()))
	nums_sorted = nums.copy()
	nums_sorted.sort()
	idxs = dict()
	for i in range(0, len(nums)):
		idxs[nums_sorted[i]] = i
	idx_sorted = -1
	min_pieces = 0
	for i in range(0, len(nums)):
		if idx_sorted == -1:
			min_pieces += 1
			idx_sorted = idxs[nums[i]]
		elif idx_sorted < len(nums) - 1 and nums[i] == nums_sorted[idx_sorted + 1]:
			idx_sorted += 1
		else:
			min_pieces += 1
			idx_sorted = idxs[nums[i]]
	print('YES' if min_pieces <= k else 'NO')


import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = [(a[i], i) for i in range(n)]
	b.sort()
	ns = 1
	for i in range(n - 1):
		if b[i][1] + 1 != b[i + 1][1]:
			ns += 1
	if ns <= k:
		ANS.append('YES')
	else:
		ANS.append('NO')
print('\n'.join(ANS))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sorted(a)
	d = {}
	ind = 0
	for i in range(len(s) - 1):
		d[s[i]] = s[i + 1]
	d[s[-1]] = None
	pair = 0
	for i in range(len(a) - 1):
		if d[a[i]] == a[i + 1]:
			continue
		else:
			pair = pair + 1
	pair = pair + 1
	if pair > k:
		print('No')
	else:
		print('Yes')


def sol(A, k):
	B = sorted(A)
	dic = {}
	for i in range(len(A) - 1):
		dic[A[i]] = A[i + 1]
	count = 1
	for i in range(len(B) - 1):
		if not (B[i] in dic and dic[B[i]] == B[i + 1]):
			count += 1
	return 'Yes' if count <= k else 'No'
x = int(input())
for _ in range(x):
	B = list(map(int, input().split()))
	A = list(map(int, input().split()))
	print(sol(A, B[1]))


ans = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	u = list(map(int, input().split()))
	s = sorted(u)
	ind = dict()
	for i in range(n):
		ind[s[i]] = i
	cnt = 0
	for i in range(1, n):
		if ind[u[i]] != ind[u[i - 1]] + 1:
			cnt += 1
	cnt += 1
	if cnt > k:
		ans.append('No')
	else:
		ans.append('Yes')
print('\n'.join(ans))


import math
import sys
import collections
import bisect
import time
import random
from itertools import permutations

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, k) = get_ints()
	arr = get_list()
	temp = arr.copy()
	temp.sort()
	pos = dict()
	for (i, j) in enumerate(temp):
		pos[j] = i
	ans = []
	for (i, j) in enumerate(arr):
		curr = i
		des = pos[j]
		ans.append(des - curr)
	count = 1
	prev = ans[0]
	for i in ans:
		if i == prev:
			continue
		else:
			prev = i
			count += 1
	if count <= k:
		print('Yes')
	else:
		print('No')


for t in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	a_sort = sorted(a)
	d = {}
	for i in range(n):
		try:
			d[a_sort[i]] = a_sort[i + 1]
		except:
			d[a_sort[i]] = float('inf')
	p = 0
	for i in range(n):
		try:
			if d[a[i]] != a[i + 1]:
				p += 1
		except:
			p += 1
	if p <= k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	if k == n:
		print('YES')
		continue
	mapp = dict()
	for i in range(n):
		mapp[a[i]] = i
	a.sort()
	for i in range(n):
		a[i] = mapp[a[i]]
	for i in range(1, n):
		if a[i] != a[i - 1] + 1:
			ans += 1
	if k > ans:
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(x):
	(y, z) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	w = {}
	for i in range(y):
		w[b[i]] = i
	p = 1
	ans = 1
	for i in range(1, y):
		if w[a[i - 1]] != w[a[i]] - 1:
			ans += 1
	if ans > z:
		print('No')
	else:
		print('Yes')


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 10 ** 16
md = 10 ** 9 + 7

def solve():
	(n, k) = LI()
	aa = LI()
	bb = sorted(aa)
	nxt = {}
	for i in range(n - 1):
		nxt[bb[i]] = bb[i + 1]
	nxt[bb[-1]] = inf
	for (a0, a1) in zip(aa, aa[1:]):
		if nxt[a0] == a1:
			continue
		k -= 1
	print('Yes' if k > 0 else 'No')
for testcase in range(II()):
	solve()


ali = 0
from collections import defaultdict, Counter, deque
ali = 0
ali = 0
ali = 0
from math import sqrt, log10, log, floor, factorial, gcd
ali = 0
ali = 0
ali = 0
from bisect import bisect_left, bisect_right
ali = 0
ali = 0
ali = 0
from itertools import permutations, combinations
ali = 0
ali = 0
ali = 0
import sys, io, os
ali = 0
ali = 0
ali = 0
input = sys.stdin.readline
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
inf = float('inf')
ali = 0
ali = 0
ali = 0
mod = 10 ** 9 + 7
ali = 0
ali = 0

def get_list():
	return [int(i) for i in input().split()]
	ali = 0
ali = 0

def yn(a):
	print('YES' if a else 'NO')
	ali = 0
ali = 0
ali = 0
ceil = lambda a, b: (a + b - 1) // b
ali = 0
ali = 0
ali = 0
t = int(input())
ali = 0
ali = 0
for i in range(t):
	ali = 0
	(n, k) = [int(i) for i in input().split()]
	ali = 0
	ali = 0
	ali = 0
	l = [int(i) for i in input().split()]
	ali = 0
	ali = 0
	ali = 0
	m = [[l[i], i] for i in range(n)]
	ali = 0
	ali = 0
	ali = 0
	m.sort()
	ali = 0
	ali = 0
	ali = 0
	counter = 0
	ali = 0
	ali = 0
	for i in range(1, n):
		ali = 0
		if m[i][1] - m[i - 1][1] > 1:
			ali = 0
			counter += 1
			ali = 0
			ali = 0
		elif m[i][1] - m[i - 1][1] < 0:
			ali = 0
			counter += 1
			ali = 0
			ali = 0
	ali = 0
	ali = 0
	ali = 0
	yn(counter + 1 <= k)
	ali = 0
	ali = 0


def binarysearch(array, n):
	i = 0
	j = len(array) - 1
	while i < j:
		mid = (i + j) // 2
		if array[mid] == n:
			return mid
		elif array[mid] < n:
			i = mid + 1
		else:
			j = mid - 1
	else:
		return i
t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	array = list(map(int, input().split()))
	array2 = sorted(array)
	s = 0
	i = 0
	while i < n:
		first = binarysearch(array2, array[i])
		if first == n - 1 or i == n - 1:
			s += 1
			i += 1
		elif array2[first + 1] != array[i + 1]:
			s += 1
			i += 1
		else:
			j = 1
			while first + j <= n - 1 and i + j <= n - 1 and (array2[first + j] == array[i + j]):
				j += 1
			else:
				i += j
				s += 1
	else:
		print('YES' if k >= s else 'NO')


nubor = int(input())
for _ in range(nubor):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	b = list(map(int, input().split()))
	x = b[:n]
	k_min = 1
	a = sorted(list(map(list, zip(x, range(n)))))
	for i in range(1, n):
		if a[i - 1][1] + 1 != a[i][1]:
			k_min = k_min + 1
	k_print = 'Yes' if k_min <= k else 'No'
	print(k_print)


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, p) = map(int, input().split())
	a = [int(x) for x in input().split()]
	vals = sorted(a)
	d = {}
	for i in range(n):
		d[vals[i]] = i
	k = 0
	for i in range(n - 1):
		x = d[a[i + 1]]
		y = d[a[i]]
		if x != y + 1:
			k += 1
	k += 1
	if k <= p:
		print('yes')
	else:
		print('no')


T = int(input())
for case in range(1, T + 1):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in range(N):
		A[i] = (A[i], i)
	A.sort()
	last = A[0][1]
	g = 1
	for (n, pos) in A[1:]:
		if pos != last + 1:
			g += 1
		last = pos
	if g > K:
		print('No')
	else:
		print('Yes')


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	ind = dict()
	for i in range(n):
		ind[b[i]] = i
	crack = 0
	i = 1
	while i < n:
		if ind[a[i]] - ind[a[i - 1]] != 1:
			crack += 1
		i += 1
	if crack + 1 <= k or a == sorted(a):
		print('Yes')
	else:
		print('No')


from bisect import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = A.copy()
	B.sort()
	if k > n:
		print('NO')
	elif k == n:
		print('YES')
	else:
		ans = 0
		for i in range(0, n - 1):
			t = bisect_right(B, A[i])
			if t < n:
				if B[t] == A[i + 1]:
					ans += 1
		if k + ans >= n:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	temp = sorted(arr)
	d = {}
	for i in range(len(temp)):
		d[temp[i]] = i
	cnt = 1
	for i in range(0, n - 1):
		if d[arr[i + 1]] - d[arr[i]] != 1:
			cnt += 1
	if cnt <= k:
		print('Yes')
	else:
		print('No')


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	temp = sorted(arr)
	val = {}
	for i in range(n):
		val[temp[i]] = i
	parts = 1
	i = 0
	while i < n - 1:
		if val[arr[i + 1]] != val[arr[i]] + 1:
			parts += 1
		i += 1
	if parts > k or n < k:
		print('No')
	else:
		print('Yes')


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [a[i] for i in range(n)]
	b.sort()
	loc = {}
	for i in range(n):
		loc[b[i]] = i
	for i in range(n):
		a[i] = loc[a[i]]
	count = 1
	for i in range(1, n):
		if a[i] != a[i - 1] + 1:
			count += 1
	if count <= k:
		print('Yes')
	else:
		print('No')


from collections import defaultdict
INF = 10 ** 9 + 2
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [-INF] + sorted(a)
	lookup = defaultdict(list)
	for i in range(1, n + 1):
		lookup[b[i]] = b[i - 1]
	cnt = 0
	cur = -INF - 5
	for (i, num) in enumerate(a):
		if cur != lookup[num]:
			cnt += 1
		cur = num
	if cnt > k:
		print('No')
	else:
		print('Yes')


def YES():
	return 'YES'

def NO():
	return 'NO'

def process(numbers, max_failure):
	not_sorted = numbers
	sorted_list = sorted(numbers)
	dictionary = dict()
	before = sorted_list[0]
	dictionary[before] = 'begin'
	for _ in sorted_list[1:]:
		dictionary[_] = before
		before = _
	for (index, _) in enumerate(not_sorted[1:]):
		num = not_sorted[index]
		num2 = dictionary[_]
		if num != num2:
			max_failure -= 1
	return YES() if max_failure > 0 else NO()
test_case = int(input())

def to_int(numbers):
	numbers_int = list()
	for _ in numbers[:]:
		numbers_int.append(int(_))
	return numbers_int
for _ in range(test_case):
	(len, max_failure) = input().split(' ')
	numbers = input().split(' ')
	print(process(to_int(numbers), int(max_failure)))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	A = sorted([(A[i], i) for i in range(n)])
	c = 0
	for i in range(1, n):
		if A[i][1] != A[i - 1][1] + 1:
			c += 1
	print('YES' if c < k else 'NO')


import io, os, sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
cases = []
for _ in range(t):
	(_, k) = map(int, input().decode().split())
	cases.append((k, [int(n) for n in input().decode().split()]))
for (k, arr) in cases:
	arr_sorted = sorted(arr)
	arr_num_index = {num: i for (i, num) in enumerate(arr)}
	min_k = 0
	i = 0
	len_arr = len(arr)
	while i < len_arr:
		min_k += 1
		j = arr_num_index[arr_sorted[i]]
		while j < len_arr - 1 and i < len_arr - 1 and (arr[j + 1] == arr_sorted[i + 1]):
			i += 1
			j += 1
		i += 1
	if min_k <= k:
		sys.stdout.write('Yes\n')
	else:
		sys.stdout.write('No\n')


import math, io, os, sys
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	r = 0
	a = list(map(int, input().split()))
	success = 1
	d = {}
	b = sorted(a)
	mn = b[0]
	for i in range(0, len(b)):
		d[b[i]] = b[i - 1]
	for i in range(1, len(a)):
		if a[i] > a[i - 1] and (a[i] == mn or d[a[i]] == a[i - 1]):
			continue
		else:
			r += 1
			if r > k - 1:
				success = 0
				break
	if success:
		print('Yes')
	else:
		print('No')


def solve(n, k, arr):
	p = {x: i for (i, x) in enumerate(sorted(arr))}
	a = [p[x] for x in arr]
	for i in range(n - 1):
		if a[i + 1] - a[i] != 1:
			k -= 1
	return k >= 1
import sys
input = lambda : sys.stdin.readline().rstrip()
ans = ['NO', 'YES']
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(ans[solve(n, k, arr)])


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, k, arr):
	tmp = arr.copy()
	tmp.sort()
	d = {}
	for i in range(n):
		d[tmp[i]] = i
	c = 0
	tmp = 0
	for i in range(1, n):
		if d[arr[i - 1]] + 1 == d[arr[i]]:
			tmp += 1
		else:
			c += 1
			tmp = 0
	c = c + 1
	if c <= k:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	(n, k) = get_int()
	arr = int_arr()
	solve(n, k, arr)


def moamen2(sArray, array, k):
	nextV = {}
	for i in range(len(array) - 1):
		nextV[sArray[i]] = sArray[i + 1]
	answer = 1
	nextV[sArray[len(array) - 1]] = None
	for i in range(len(array)):
		if i == 0:
			pass
		elif nextV[array[i - 1]] != array[i]:
			answer += 1
	if answer <= k:
		print('Yes')
	else:
		print('No')
n = int(input())
for i in range(n):
	(nElements, k) = map(int, input().split())
	array = list(map(int, input().split()))
	sArray = array[:]
	sArray.sort()
	moamen2(sArray, array, k)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in range(n):
		A[i] = (A[i], i)
	A.sort()
	ans = 1
	for i in range(1, n):
		if A[i][1] != A[i - 1][1] + 1:
			ans += 1
	if ans > m:
		print('No')
	else:
		print('Yes')


import sys
from bisect import bisect
from math import sqrt, ceil, floor

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(n, k) = rinput()
	a = get_list()
	b = list(sorted(a))
	index = {}
	for i in range(n):
		index[a[i]] = i
	i = 0
	parts = 0
	while i < n:
		ind = index[b[i]]
		while ind < n and i < n and (a[ind] == b[i]):
			ind += 1
			i += 1
		parts += 1
	if k >= parts:
		print('YES')
	else:
		print('NO')