Skip to content

Instantly share code, notes, and snippets.

@Abdujabbar
Created February 1, 2016 07:12
Show Gist options
  • Save Abdujabbar/e8bb8efbcaf30fe778f9 to your computer and use it in GitHub Desktop.
Save Abdujabbar/e8bb8efbcaf30fe778f9 to your computer and use it in GitHub Desktop.
flatland space stations
__author__ = 'abdujabbor'
n, m = [int(x) for x in input().split()]
lst = [0] * n
zeros = sorted([int(x) for x in input().split()])
lz = len(zeros)
if len(zeros) == n:
print(0)
else:
for i in range(lz):
lst[zeros[i]] = -1
for i in range(n):
if lst[i] == -1:
continue
else:
j = 0
while j < lz - 1 and zeros[j] < i:
j += 1
lst[i] = min(abs(i - zeros[j]), (i - zeros[j - 1]))
print(max(lst))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment