https://www.acmicpc.net/problem/2805

6달전에 풀었던 문제를 오늘 다시 만나게 되었다.
그때보다는 확실히 쉬워진 것 같다!
n,m = list(map(int,input().split()))
array = list(map(int, input().split()))
start = 0
end = max(array)
result = 0
while(start<=end):
total = 0
mid = (start+end) // 2
for i in array:
if i > mid:
total += i - mid
if total < m :
end = mid - 1
else:
result = mid
start = mid + 1
print(result)