Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. import math
  2.  
  3. [n, m] = [int(i) for i in raw_input().split(' ')]
  4. f = [int(i) for i in raw_input().split(' ')]
  5.  
  6. f = sorted(f);
  7. minDist = min([(f[i + n - 1] - f[i]) for i in range(m - n + 1)]) if m > n else f[n - 1] - f[0]
  8. print minDist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement