Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, k = map(int, input().split())
- a = list(map(int, input().split()))
- l = 0
- r = a[-1] - a[0] + 1
- while r - l > 1:
- x = (r + l) // 2
- cnt = 1
- lst = a[0]
- for i in range(1, n):
- if a[i] - lst >= x:
- lst = a[i]
- cnt += 1
- if cnt >= k:
- l = x
- else:
- r = x
- print(l)
Advertisement
Add Comment
Please, Sign In to add comment