Guest User

Untitled

a guest
Oct 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. n, k = [int(i) for i in input().split()]
  2. dots = [int(i)-1 for i in input().split()]
  3.  
  4. first = dots[0]
  5. last = dots[len(dots) - 1]
  6.  
  7. max_l = (last - first) // k + (1 if (last - first) % k != 0 else 0)
  8.  
  9. i = max_l
  10.  
  11. while True:
  12. cur_pos = first
  13. l = 0
  14. f = False
  15. while True:
  16. cur_pos += i
  17. l += 1
  18. if cur_pos in dots:
  19. if cur_pos == last:
  20. if l<=k:
  21. f = True
  22. break
  23. else:
  24. break
  25. if f:
  26. break
  27. i += 1
  28. print(i)
Add Comment
Please, Sign In to add comment