p. 201
n,m = map(int, input().split())
array=list(map(int, input().split()))
start=0
end=max(array)
result = 0
while start<=end:
length=0
middle=(start+end)//2
for i in array:
if i > middle:
length += (i-middle)
if length < m:
end=middle-1
else:
start=middle+1
result=middle
print(result)
파라메트릭 서치 유형
댓글