P1873 [COCI 2011/2012 #5] EKO / 砍树 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
n, m = map(int,input().split())data = list(map(int,input().split()))
h = 0
def check(mid):h = 0for i in data:if i>mid:h += (i-mid)if h < m:return Trueelse:return Falsel = 0
r = max(data)
while l<=r:mid = (l+r)//2if check(mid):r = mid-1else:l = mid+1print(f'{l-1}')
其实这道题的重点二分法的边界,左右边界在更新的时候怎么更新,什么时候更新