-
Notifications
You must be signed in to change notification settings - Fork 0
/
MTYFRI.py
37 lines (36 loc) · 847 Bytes
/
MTYFRI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# cook your dish here
flag = 0
t = int(input())
while(t>0) :
flag = 0
M,K = input().split()
m = int(M)
k = int(K)
a = [int(x) for x in input().split()]
motu = []
tomu = []
for i in range (0,m) :
if(i%2)==0 :
motu += [a[i]]
else :
tomu += [a[i]]
motu_sum = sum(motu)
tomu_sum = sum(tomu)
if tomu_sum>motu_sum :
print("YES")
else :
while k>0 :
max1 = max(motu)
min1 = min(tomu)
tomu_sum += max1
motu_sum -= max1
motu_sum+=min1
tomu_sum-=min1
if tomu_sum>motu_sum :
print("YES")
flag = 1
break
k-=1
if flag==0 :
print("NO")
t-=1