첫 번째 풀이
# 입력
n, m = map(int,input().split())
tree = list(map(int,input().split()))
h = max(tree)
current = 0
# 함수
def relu(x):
if x>0:
return x
else:
return 0
# 처리
while current < m:
temp = 0
for t in tree:
temp += relu(t-h)
current = temp
h -= 1
print(h+1)
두 번째 풀이
# 입력
n, m = map(int,input().split())
tree = list(map(int,input().split()))
start,end = 1,sum(tree)
# 함수
def relu(x):
if x>0:
return x
else:
return 0
# 처리
while start <= end:
mid = (start + end) // 2
temp = 0
for t in tree:
temp += relu(t-mid)
if temp >= m:
start = mid + 1
else:
end = mid-1
print(end)