Fácil25 pts
Flatland Space Stations
Traducción al español en progresoEl contenido detallado de esta lección aún se está traduciendo. Mientras tanto, se muestra en inglés.
Flatland has n cities in a line (0 to n-1). Some cities have space stations. Find the maximum distance from any city to its nearest space station. Example: n=5, stations at [0,4]. City 0: distance 0, City 1: min(1,3)=1, City 2: min(2,2)=2, City 3: min(3,1)=1, City 4: distance 0. Maximum is 2.
Entrada
First line: n m (space-separated, m is number of stations). Second line: m space-separated integers (city indices with stations).
Salida
A single integer: the maximum distance to nearest space station.
Ejemplo
5 2 0 4
Esperado
2
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.