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 bc6d49e commit 0ae1201
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Algorithm/BOJ/2805.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
n, m = map(int, input().split())
array = list(map(int, input().split()))

start = 0
end = max(array)

result = 0

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

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

print(result)

0 comments on commit 0ae1201

Please sign in to comment.