Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def checkoperations(l,maxt,op):
- yes = 0
- for p in range(n // 2 - (n + 1) % 2, n):
- if (maxt - l[p] > 0):
- yes = yes + (maxt - l[p])
- if (yes > op):
- return False
- if (yes<op+1):
- return True
- else:
- return False
- n=int(input())
- k=int(input())
- a=[]
- for i in range(n):
- a.append(int(input()))
- a.sort()
- start=1
- end=k+max(a)
- while start<end+1:
- maxtaste = (start + end)//2
- if (checkoperations(a,maxtaste, k)):
- start = maxtaste + 1
- else :
- end = maxtaste - 1
- answer=start-1
- print(answer)
Advertisement
Add Comment
Please, Sign In to add comment