-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2110.py
More file actions
27 lines (22 loc) · 707 Bytes
/
2110.py
File metadata and controls
27 lines (22 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 공유기 설치
N, C = map(int, input().split())
buildings = sorted([int(input()) for _ in range(N)])
start, end = 0, buildings[len(buildings)-1]
minimumDistances = []
while start <= end:
countRouter = 1
lastInstalled = 0
mid = (start + end) // 2
for index in range(1, len(buildings)):
distance = buildings[index] - buildings[lastInstalled]
if (distance >= mid):
countRouter += 1
lastInstalled = index
if (countRouter >= C):
minimumDistances.append(mid)
start = mid+1
break
if index == len(buildings)-1:
end = mid-1
break
print(max(minimumDistances))