Created
January 7, 2020 07:46
-
-
Save inspirit941/75b70d83fa8523490e9120f52d8f81a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
k, n = map(int, sys.stdin.readline().split()) | |
arr = [] | |
for _ in range(k): | |
arr.append(int(sys.stdin.readline())) | |
lower_bound, upper_bound = 1, max(arr) | |
result = 0 | |
while lower_bound <= upper_bound: | |
# 몇 cm의 크기로 잘라낼 것인지. | |
mid = (lower_bound + upper_bound) // 2 | |
# 해당 크기로 잘라냈을 때 몇 개의 랜선이 모이는지 | |
cut_sum = sum([(i // mid) for i in arr]) | |
# 잘라낸 개수가 기준보다 많다면, 더 큰 단위로 잘라서 개수를 줄여도 된다. | |
if cut_sum >= n: | |
result = mid | |
lower_bound = mid + 1 | |
# 잘라낸 개수가 기준보다 적다면, 더 작은 단위로 잘라서 개수를 늘려야 한다. | |
elif cut_sum < n: | |
upper_bound = mid - 1 | |
print(result) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment