Skip to content

Commit

Permalink
[UPD] Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tony9402 authored Nov 29, 2021
1 parent f583171 commit 3b84751
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions solution/binary_search/1477/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Authored by : yj2221
# Co-authored by : -
# Link : http://boj.kr/b93ed1e8f2a7413fa8fe39483692604f
# Co-authored by : tony9402
# Link : http://boj.kr/3fe7ddd4b0c2437882109089a41a0349

import sys

Expand All @@ -11,19 +11,20 @@ def input():
rests = [0] + list(map(int, input().split())) + [l]
rests.sort()

_min = 0
_max = l
answer = _max
while _min <= _max:
mid = (_min + _max) // 2
low = 1
high = l
answer = high
while low <= high:
mid = (low + high) // 2

cnt = 0
for i in range(n+1):
cnt += (rests[i+1] - rests[i] - 1) // mid

if cnt<=m:
answer = mid
_max = mid-1
high = mid - 1
else:
_min = mid+1
low = mid + 1

print(answer)
print(answer)

0 comments on commit 3b84751

Please sign in to comment.