백준 2805번
https://www.acmicpc.net/problem/2805

import sys N, M = map(int,input().split()) tree = sorted(list(map(int,sys.stdin.readline().split()))) min_length = 0 max_length = max(tree) while min_length <= max_length: get_sum = 0 mid_length = (min_length + max_length)//2 for i in (tree): if i > mid_length: get_sum += (i - mid_length) if get_sum < M: max_length = mid_length -1 else: min_length = mid_length +1 print(max_length)