Problem p02970 (python)

Fixed submission:
#coding:utf-8
n, d = map(int, input().split())

#監視員は2D+1本の木を監視する
#最小の監視員はN/2D+1 の切り上げ
print(-(-n // (2*d + 1)))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, d = map(int, input().split())

flag = [0] * n
people = 1

#端を埋める
for i in range(0,2*d):
    flag[i] = 1

#print(flag)
#print(sum(flag))

if sum(flag) < n:
    for i in range(n-2*d-1, n):
        flag[i] = 1
    people += 1


#print(flag)

for i in range(2*d, n-2*d):
    if flag[i] == 0:
        people += 1
        #print(i)
        for j in range(i, i+d+1):
            if j > n-d:
                break 
            else:
                flag[j] = 1
        #print(flag)


#print(flag)
print(people)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, d = map(int, input().split())

flag = [0] * n
people = 1

#端を埋める
for i in range(0,2*d):
    flag[i] = 1


for i in range(n-2*d-1, n):
    flag[i] = 1

if sum(flag) != n:
    people += 1

#print(flag)

for i in range(2*d, n-2*d):
    if flag[i] == 0:
        people += 1
        #print(i)
        for j in range(i, i+d+1):
            if j > n-d:
                break 
            else:
                flag[j] = 1
        #print(flag)


#print(flag)
print(people)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, d = map(int, input().split())

flag = [0] * n
people = 0

#端を埋める
for i in range(0,2*d):
    flag[i] = 1

if sum(flag) != n:
    people += 1

for i in range(n-2*d-1, n):
    flag[i] = 1

if sum(flag) != n:
    people += 1

#print(flag)

for i in range(2*d, n-2*d):
    if flag[i] == 0:
        people += 1
        #print(i)
        for j in range(i, i+d+1):
            if j > n-d:
                break 
            else:
                flag[j] = 1
        #print(flag)


#print(flag)
print(people)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, d = map(int, input().split())

flag = [0] * n
people = 1

#端を埋める
for i in range(0,2*d):
    flag[i] = 1

if sum(flag) != n:
    people += 1
for i in range(n-2*d-1, n):
    flag[i] = 1



#print(flag)

for i in range(2*d, n-2*d):
    if flag[i] == 0:
        people += 1
        #print(i)
        for j in range(i, i+d+1):
            if j > n-d:
                break 
            else:
                flag[j] = 1
        #print(flag)


#print(flag)
print(people)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, d = map(int, input().split())

flag = [0] * n
people = 0

for i in range(0,d):
    flag[i] = 1

for i in range(n-d, n):
    flag[i] = 1

#print(flag)

for i in range(d, n):
    if flag[i] == 0:
        people += 1
        #print(i)
        for j in range(i, i+d+1):
            if j > n-d:
                break 
            else:
                flag[j] = 1
        #print(flag)


#print(flag)
print(people)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n, d = map(int, input().split())

flag = [0] * n
people = 0

for i in range(0,d):
    flag[i] = 1


for i in range(d, n):
    if flag[i] == 0:
        people += 1
        #print(i)
        for j in range(i, i+d+1):
            if j > n-d:
                flag = [1] * n
                break 
            else:
                flag[j] = 1
        #print(flag)


#print(flag)
print(people)