Skip to content

Commit

Permalink
[Add] 1477 python solution
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjun0627 committed Sep 7, 2021
1 parent 5e9a002 commit f583171
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions solution/binary_search/1477/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Authored by : yj2221
# Co-authored by : -
# Link : http://boj.kr/b93ed1e8f2a7413fa8fe39483692604f

import sys

def input():
return sys.stdin.readline().rstrip()

n, m, l = map(int, input().split())
rests = [0] + list(map(int, input().split())) + [l]
rests.sort()

_min = 0
_max = l
answer = _max
while _min <= _max:
mid = (_min + _max) // 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
else:
_min = mid+1

print(answer)

0 comments on commit f583171

Please sign in to comment.