Skip to content

Commit

Permalink
예산 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezidayzi committed Mar 6, 2022
1 parent 0ae1201 commit 0cf4a2b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Algorithm/BOJ/2512.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
n = int(input())
array = list(map(int, input().split()))
m = int(input())

start = 0
end = max(array)

result = 0

while(start <= end):
total = 0
mid = (start + end) // 2
for x in array:
if x >= mid:
total += mid
else:
total += x

if total <= m:
start = mid + 1
else:
end = mid - 1

print(end)

0 comments on commit 0cf4a2b

Please sign in to comment.