🍋 문제링크


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

🍎 코드 제출 기록 (메모리 및 시간)


제출 날짜

2021/04/23

메모리

130620 KB

시간

272 ms

🥝 메모


🍉 Code


N, C = map(int, input().split())
house = []
for i in range(N):
    house.append(int(input()))

house.sort()
start = 1
end = house[-1] - house[0]
answer = 0

while start <= end:
    mid = (start + end) // 2
    count = 1
    position = house[0]

    for i in range(1, len(house)):
        if position + mid <= house[i]:
            count += 1
            position = house[i]

    if count < C:
        end = mid - 1
    else:
        start = mid + 1
        answer = mid

print(answer)