Skip to content

Commit 1be05bb

Browse files
committed
84차 2번 문제 풀이 (푸는중)
1 parent a48ee81 commit 1be05bb

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

live8/test84/문제2/박희경.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
sum(k // result) == n
3+
이때 최대 result 구하기
4+
"""
5+
6+
import sys
7+
8+
input = sys.stdin.readline
9+
10+
11+
def binary_search(arr):
12+
start, end = 1, max(arr)
13+
while start <= end:
14+
mid = (start + end) // 2 # 반으로 자른 길이
15+
cnt = 0
16+
for i in cm:
17+
cnt += i // mid
18+
if cnt > n: # 길이를 늘릴 필요가 있음
19+
start = mid + 1
20+
else:
21+
end = mid - 1
22+
return end
23+
24+
25+
k, n = map(int, input().split())
26+
cm = []
27+
for _ in range(k):
28+
cm.append(int(input()))
29+
30+
cm.sort() # [457, 539, 743, 802]
31+
print(binary_search(cm))
32+
33+
34+
"""
35+
4 11
36+
802
37+
743
38+
457
39+
539
40+
"""

0 commit comments

Comments
 (0)