Advertisement
T-D-K

Untitled

Jun 14th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. n, k = map(int, input().split())
  2. a, b, c = map(int, input().split())
  3. k = k % n
  4. s = n
  5. s = min(s, abs(a - k))
  6. s = min(s, k + n - a)
  7. s = min(s, abs(b - k))
  8. s = min(s, k + n - b)
  9. s = min(s, abs(c - k))
  10. s = min(s, k + n - c)
  11. print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement