# BOJ - 2110 - 공유기 설치

Updated:

```
import sys
sys.setrecursionlimit(10 ** 9)
answer = 0
def solve(arr, N, C, minimum, maximum):
if minimum > maximum:
return
dist = (maximum + minimum) // 2
cnt = 1
target = 0
for idx in range(N):
if arr[idx] >= arr[target] + dist:
cnt += 1
target = idx
if cnt >= C:
global answer
answer = max(answer, dist)
solve(arr, N, C, dist + 1, maximum)
else:
solve(arr, N, C, minimum, dist - 1)
def solution():
global answer
N, C = map(int, sys.stdin.readline().split())
arr = [int(sys.stdin.readline()) for _ in range(N)]
arr.sort()
solve(arr, N, C, 1, (arr[-1] - arr[0]) // (C - 1) + 1)
print(str(answer))
solution()
```

https://www.acmicpc.net/problem/2110

## Leave a comment