Created
February 7, 2020 06:36
-
-
Save inspirit941/86a53480960b6d1e7d26ecf20a51825e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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