You are viewing a single comment's thread. Return to all comments →
I used the same technique but i am failing the test cases.
Code :
import sys
n,m = input().strip().split(' ') n,m = [int(n),int(m)]
space_stations = [0] space_stations += [int(c_temp) for c_temp in input().strip().split(' ')] space_stations.append(n)
space_stations.sort()
max_distance = 0
d1 = space_stations[1] d2 = n - space_stations[m + 1]
for j in range(m + 1): distance = space_stations[j + 1] - space_stations[j] if distance > max_distance: max_distance = distance
max_distance /= 2
print(int(max(max_distance, d1, d2)))
Seems like cookies are disabled on this browser, please enable them to open this website
Flatland Space Stations
You are viewing a single comment's thread. Return to all comments →
I used the same technique but i am failing the test cases.
Code :
!/bin/python3
import sys
n,m = input().strip().split(' ') n,m = [int(n),int(m)]
space_stations = [0] space_stations += [int(c_temp) for c_temp in input().strip().split(' ')] space_stations.append(n)
space_stations.sort()
max_distance = 0
d1 = space_stations[1] d2 = n - space_stations[m + 1]
for j in range(m + 1): distance = space_stations[j + 1] - space_stations[j] if distance > max_distance: max_distance = distance
max_distance /= 2
print(int(max(max_distance, d1, d2)))