Skip to content

Instantly share code, notes, and snippets.

@jo32
Created October 10, 2015 06:56
Show Gist options
  • Select an option

  • Save jo32/ee4468bcd7ba002fe700 to your computer and use it in GitHub Desktop.

Select an option

Save jo32/ee4468bcd7ba002fe700 to your computer and use it in GitHub Desktop.
CODEFORCES 337A
import math
[n, m] = [int(i) for i in raw_input().split(' ')]
f = [int(i) for i in raw_input().split(' ')]
f = sorted(f);
minDist = min([(f[i + n - 1] - f[i]) for i in range(m - n + 1)]) if m > n else f[n - 1] - f[0]
print minDist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment