Python求助,二分答案不知道错哪了
查看原帖
Python求助,二分答案不知道错哪了
1227790
MC_xjhjdA楼主2025/1/16 11:40
n,m=map(int,input().split())
li=[int(x) for x in input().split()]
def ch(g):
    tot=0
    for gx in li:
        tot+=max(gx-g,0)
    return tot>=m
l,r=1,10**9
while l<r:
    m=(l+r)//2
    if ch(m):
        l=m+1
    else:
        r=m
print(l)
2025/1/16 11:40
加载中...