Skip to content

Instantly share code, notes, and snippets.

@inspirit941
Created February 7, 2020 06:36
Show Gist options
  • Save inspirit941/86a53480960b6d1e7d26ecf20a51825e to your computer and use it in GitHub Desktop.
Save inspirit941/86a53480960b6d1e7d26ecf20a51825e to your computer and use it in GitHub Desktop.
def solution(budgets, M):
mins, maxs = 0, max(budgets)
answer = 0
while mins <= maxs:
mid = (mins + maxs) // 2
temp = [i if i < mid else mid for i in budgets]
if sum(temp) > M:
maxs = mid - 1
elif sum(temp) <= M:
answer = mid
mins = mid + 1
return answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment