Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, k = [int(i) for i in input().split()]
- dots = [int(i)-1 for i in input().split()]
- first = dots[0]
- last = dots[len(dots) - 1]
- max_l = (last - first) // k + (1 if (last - first) % k != 0 else 0)
- i = max_l
- while True:
- cur_pos = first
- l = 0
- f = False
- while True:
- cur_pos += i
- l += 1
- if cur_pos in dots:
- if cur_pos == last:
- if l<=k:
- f = True
- break
- else:
- break
- if f:
- break
- i += 1
- print(i)
Add Comment
Please, Sign In to add comment