From ca4290be6f5e16cd2f381f2dac90870336909c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=ED=98=9C=EC=9B=90?= <127714800+janghw0126@users.noreply.github.com> Date: Sun, 3 Nov 2024 19:55:14 +0900 Subject: [PATCH] =?UTF-8?q?2024-11-03=20=EB=9E=9C=EC=84=A0=20=EC=9E=90?= =?UTF-8?q?=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- janghw0126/README.md | 1 + ...0 \354\236\220\353\245\264\352\270\260.py" | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 "janghw0126/\354\235\264\354\247\204 \355\203\220\354\203\211/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" diff --git a/janghw0126/README.md b/janghw0126/README.md index 3673439..067ee05 100644 --- a/janghw0126/README.md +++ b/janghw0126/README.md @@ -52,4 +52,5 @@ | 14차시 | 2024.10.5 | BFS | 적록색약 |[#172](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/172) | | 15차시 | 2024.10.12 | 이진 탐색 | 징검다리 |[#176](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/176) | | 16차시 | 2024.10.30 | 스택 | 문자열 폭발 |[#183](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/183) | +| 17차시 | 2024.11.3 | 이진 탐색 | 랜선 자르기 |[#186](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/186) | --- \ No newline at end of file diff --git "a/janghw0126/\354\235\264\354\247\204 \355\203\220\354\203\211/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" "b/janghw0126/\354\235\264\354\247\204 \355\203\220\354\203\211/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..eb77b52 --- /dev/null +++ "b/janghw0126/\354\235\264\354\247\204 \355\203\220\354\203\211/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,21 @@ +import sys + +# 입력 처리 +K, N = map(int, sys.stdin.readline().strip().split()) +cables = [int(sys.stdin.readline().strip()) for _ in range(K)] + +# 이진 탐색 범위 설정 +low, high = 1, max(cables) + +while low <= high: + mid = (low + high) // 2 + # mid 길이로 자른 랜선 개수 합산 + count = sum(cable // mid for cable in cables) + + if count >= N: + low = mid + 1 + else: + high = mid - 1 + +# 최대 길이 출력 +print(high) \ No newline at end of file