From 09c52974830d08a19985c4db334fcb4189a9f027 Mon Sep 17 00:00:00 2001 From: JSPark <48265129+pknujsp@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:24:28 +0900 Subject: [PATCH] 2024-02-21 --- pknujsp/README.md | 5 ++-- ...4 \354\204\270\354\232\260\352\270\260.py" | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 "pknujsp/\354\235\264\354\247\204\355\203\220\354\203\211/36-\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260.py" diff --git a/pknujsp/README.md b/pknujsp/README.md index c9fac876..606d5e96 100644 --- a/pknujsp/README.md +++ b/pknujsp/README.md @@ -35,5 +35,6 @@ | 31차시 | 2024.01.30 | SORT | [멀티버스 Ⅱ](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) | | 32차시 | 2024.02.04 | BFS | [숨바꼭질 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) | | 33차시 | 2024.02.06 | 큐 | [철로](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/132) | -| 34차시 | 2024.02.12 | BFS | [이분 그래프](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/135) | -| 35차시 | 2024.02.18 | 그리디 | [선물할인](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/137) | +| 34차시 | 2024.02.12 | BFS | [이분 그래프](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/135) | +| 35차시 | 2024.02.18 | 그리디 | [선물할인](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/137) | +| 36차시 | 2024.02.21 | 이진탐색 | [휴게소 세우기](https://www.acmicpc.net/problem/1477) | [#143](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/143) | \ No newline at end of file diff --git "a/pknujsp/\354\235\264\354\247\204\355\203\220\354\203\211/36-\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260.py" "b/pknujsp/\354\235\264\354\247\204\355\203\220\354\203\211/36-\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260.py" new file mode 100644 index 00000000..277ba120 --- /dev/null +++ "b/pknujsp/\354\235\264\354\247\204\355\203\220\354\203\211/36-\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260.py" @@ -0,0 +1,30 @@ +N, M, L = map(int, input().split()) +array = list(map(int, input().split())) +array.sort() + +left = 1 +right = L - 1 + +min_max_distance = right + +while left <= right: + max_distance = (left + right) // 2 + extra_added = 0 + last_installed_x = 0 + + for installed_x in array: + if installed_x - last_installed_x > max_distance: + extra_added += (installed_x - last_installed_x - 1) // max_distance + + last_installed_x = installed_x + + if L - last_installed_x > max_distance: + extra_added += (L - last_installed_x - 1) // max_distance + + if extra_added > M: + left = max_distance + 1 + else: + right = max_distance - 1 + +print(left) + \ No newline at end of file