https://school.programmers.co.kr/learn/courses/30/lessons/12979
import math
def solution(n, stations, w):
idx = 1
answer = 0
for i in stations:
left ,right = i-w, i+w
if left < 1:
left = 1
if right > n :
right = n
answer += math.ceil((left - idx) / (2*w+1))
idx = right + 1
if n - idx >= 0 :
answer += math.ceil((n-idx+1) / (2*w+1))
return answer