Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, b, c = map(int, input().split())
- heights = []
- for i in range(n):
- heights.append(int(input()))
- heights.sort()
- l = -1
- r = heights[-1]
- def check(g, b, c, heights):
- i = 0
- while b:
- if i + c - 1 >= len(heights):
- return False
- if heights[i+c-1] - heights[i] <= g:
- b -= 1
- i = i + c
- else:
- i += 1
- return True
- while r - l > 1:
- g = l + (r - l) // 2
- if check(g, b, c, heights):
- r = g
- else:
- l = g
- print(r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement