def get_wood_amount(trees, cut_height):
# 计算砍下的木材总长度
wood = sum(tree - cut_height for tree in trees if tree > cut_height)
return wood
def find_max_height(trees, m):
low, high = 0, max(trees)
result = 0
while low <= high:
mid = (low + high) // 2
wood = get_wood_amount(trees, mid)
if wood >= m:
result = mid
low = mid + 1
else:
high = mid - 1
return result
# 读取输入
n, m = map(int, input().split())
trees = list(map(int, input().split()))
# 计算结果
max_cut_height = find_max_height(trees, m)
# 输出结果
print(max_cut_height)
0 回复
0 转发
0 喜欢
3 阅读



