From 742bec77bd6c2dacbe398810819cb1f4cbe5996c Mon Sep 17 00:00:00 2001 From: tgyuuAn Date: Thu, 16 Jan 2025 17:43:08 +0900 Subject: [PATCH] 2025-01-16 --- tgyuuAn/README.md | 3 +- ...4 \354\236\220\353\245\264\352\270\260.py" | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 "tgyuuAn/\354\235\264\353\266\204 \355\203\220\354\203\211/\355\206\265\353\202\230\353\254\264 \354\236\220\353\245\264\352\270\260.py" diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index db250b7..6883eb7 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -65,8 +65,6 @@ | 61차시 | 2024.06.20 | 크루스칼 | 우주신과의 교감 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/212 | 62차시 | 2024.07.01 | DP | 우수 마을 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/214 | 63차시 | 2024.07.08 | BFS | 로고 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/216 -| 62차시 | 2024.07.01 | DP | 우수 마을 | https://github.com/AlgoLeadMe/AlgoLeadMse-1/pull/214 -| 63차시 | 2024.07.08 | BFS | 로고 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/216 | 64차시 | 2024.07.12 | 최소 공통 조상 | K진 트리 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/217 | 65차시 | 2024.07.19 | 최소 공통 조상 | 가장 가까운 공통 조상 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/220 | 66차시 | 2024.07.22 | DP | 로봇 조종하기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/222 @@ -88,4 +86,5 @@ | 82차시 | 2024.11.22 | 희소 배열 | 합성함수와 쿼리 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/257 | 83차시 | 2024.12.01 | 수학 + 구현 | 칵테일 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/259 | 84차시 | 2024.12.31 | BFS | 불! | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/261 +| 86차시 | 2025.01.16 | 이분 탐색 | 통나무 자르기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/265 --- diff --git "a/tgyuuAn/\354\235\264\353\266\204 \355\203\220\354\203\211/\355\206\265\353\202\230\353\254\264 \354\236\220\353\245\264\352\270\260.py" "b/tgyuuAn/\354\235\264\353\266\204 \355\203\220\354\203\211/\355\206\265\353\202\230\353\254\264 \354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..fbcdf99 --- /dev/null +++ "b/tgyuuAn/\354\235\264\353\266\204 \355\203\220\354\203\211/\355\206\265\353\202\230\353\254\264 \354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,43 @@ +import sys + +def input(): return sys.stdin.readline().rstrip() + +L, K, C = map(int, input().split()) +cut_points = sorted(list(map(int, input().split()))) +cut_points = [0] + cut_points + [L] + +def check(max_len): + cuts = 0 + last_cut = L + for i in range(len(cut_points) - 1, 0, -1): + if cut_points[i] - cut_points[i - 1] > max_len: + return False + if last_cut - cut_points[i - 1] > max_len: + cuts += 1 + last_cut = cut_points[i] + return cuts <= C + +left, right = 1, L +answer = L +while left <= right: + mid = (left + right) // 2 + if check(mid): + answer = mid + right = mid - 1 + else: + left = mid + 1 + +cuts = 0 +last_cut = L +first_cut = None +for i in range(len(cut_points) - 1, 0, -1): + if last_cut - cut_points[i - 1] > answer: + cuts += 1 + last_cut = cut_points[i] + if C == cuts: + first_cut = cut_points[i] + +if first_cut is None: + first_cut = cut_points[1] + +print(answer, first_cut) \ No newline at end of file