Easy python code : O(N*logN)


#1

class Solution:
def solve(self, A, B):
def cancut(height):
sum = 0
for a in A:
if a > height:
sum += a - height

        return sum >= B
    
    left = 0
    right = max(A)
    while left < right:
        mid = left + (right-left)//2
        
        if cancut(mid):
            left = mid + 1
            
        else:
            right = mid
            
    return right-1