Code:
def classCancle(k, arr):
n = 0
for a in arr:
if a <= 0: # on time
n = n+1
if k <= n:
return "NO"
return "YES"
if __name__ == '__main__':
res = []
tc = input()
for _ in range(int(tc)):
n, k = map(int,input().split())
arr = [int(i) for i in input().split()]
res.append(classCancle(k,arr))
for _ in res:
print(_)
Test Case:
2
4 3
-1 -3 4 2
4 2
0 -1 2 1
Result:
YES
NO
Test Case:
10
10 4
-93 -86 49 -62 -90 -63 40 72 11 67
10 10
23 -35 -2 58 -67 -56 -42 -73 -19 37
10 9
13 91 56 -62 96 -5 -84 -36 -46 -13
10 8
45 67 64 -50 -8 78 84 -51 99 60
10 7
26 94 -95 34 67 -97 17 52 1 86
10 2
19 29 -17 -71 -75 -27 -56 -53 65 83
10 10
-32 -3 -70 8 -40 -96 -18 -46 -21 -79
10 9
-50 0 64 14 -56 -91 -65 -36 51 -28
10 6
-58 -29 -35 -18 43 -28 -76 43 -13 6
10 1
88 -17 -96 43 83 99 25 90 -39 86
Result:
NO
YES
YES
YES
YES
NO
YES
YES
NO
NO