We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 01eac32 commit c4cd547Copy full SHA for c4cd547
심수연/3주차/260115.py
@@ -0,0 +1,37 @@
1
+# https://www.acmicpc.net/problem/1654
2
+
3
+import sys
4
+input = sys.stdin.readline
5
6
+K, N = map(int, input().split())
7
8
+lan_cable = []
9
10
+for _ in range(K):
11
+ lan_cable.append(int(input()))
12
13
+start = 1
14
+end = max(lan_cable)
15
16
+answer = 0
17
18
+while start <= end:
19
+ mid = (start + end) // 2 # 자를 랜선의 길이
20
21
+ count = 0 # 랜선 개수
22
23
+ for i in lan_cable:
24
+ count += i // mid
25
+ if count >= N:
26
+ break
27
28
+ if count >= N: # count 가 N보다 크거나 같으면
29
+ answer = mid # 자를 랜선의 길이를 answer 에 담기
30
+ start = mid + 1 # 자를 랜선의 길이를 더 키우기
31
+ else:
32
+ end = mid - 1 # 자를 랜선의 길이를 더 줄이기
33
34
+print(answer)
35
36
37
0 commit comments