Skip to content

Commit

Permalink
Merge pull request #186 from AlgoLeadMe/17-janghw0126
Browse files Browse the repository at this point in the history
17-janghw0126
  • Loading branch information
janghw0126 authored Nov 21, 2024
2 parents 2fd0e37 + ca4290b commit 8548ca1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions janghw0126/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@
| 14차시 | 2024.10.5 | BFS | <a href= "https://www.acmicpc.net/problem/10026">적록색약</a> |[#172](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/172) |
| 15차시 | 2024.10.12 | 이진 탐색 | <a href= "https://school.programmers.co.kr/learn/courses/30/lessons/43236">징검다리</a> |[#176](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/176) |
| 16차시 | 2024.10.30 | 스택 | <a href= "https://www.acmicpc.net/problem/9935">문자열 폭발</a> |[#183](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/183) |
| 17차시 | 2024.11.3 | 이진 탐색 | <a href= "https://www.acmicpc.net/problem/1654">랜선 자르기</a> |[#186](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/186) |
---
21 changes: 21 additions & 0 deletions janghw0126/이진 탐색/랜선 자르기.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8548ca1

Please sign in to comment.