Created
July 11, 2025 13:27
-
-
Save inspirit941/b60639845a9bbd5a504341c4747cac64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import math | |
import os | |
import random | |
import re | |
import sys | |
# Complete the flatlandSpaceStations function below. | |
def flatlandSpaceStations(n, c): | |
# first space, last space distance | |
c.sort() | |
max_value = max(c[0], n-c[-1]-1) | |
for idx in range(1, len(c)): | |
diff = c[idx] - c[idx-1] | |
dist = diff // 2 | |
max_value = max(max_value, dist) | |
return max_value | |
if __name__ == '__main__': | |
fptr = open(os.environ['OUTPUT_PATH'], 'w') | |
nm = input().split() | |
n = int(nm[0]) | |
m = int(nm[1]) | |
c = list(map(int, input().rstrip().split())) | |
result = flatlandSpaceStations(n, c) | |
fptr.write(str(result) + '\n') | |
fptr.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment