From f583171413396b1d8c4096d5ce5e06f0346edd61 Mon Sep 17 00:00:00 2001 From: youngjun0627 Date: Tue, 7 Sep 2021 17:36:17 +0900 Subject: [PATCH] [Add] 1477 python solution --- solution/binary_search/1477/main.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 solution/binary_search/1477/main.py diff --git a/solution/binary_search/1477/main.py b/solution/binary_search/1477/main.py new file mode 100644 index 00000000000..8705bbdb9a3 --- /dev/null +++ b/solution/binary_search/1477/main.py @@ -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) \ No newline at end of file