Submission #143579

#TimeUsernameProblemLanguageResultExecution timeMemory
143579tnbs10Rasvjeta (COCI17_rasvjeta)Cpython 3
50 / 50
29 ms3420 KiB
from math import ceil
n = int(input())
m = int(input())
k = int(input())
a = [0 for i in range(n)]
for i in range(m):
    x = int(input()) - 1
    for j in range(max(0, x - k), min(n - 1, x + k) + 1):
        a[j] = 1
i = 0
sol = 0
while i < n:
    if not a[i]:
        j = i + 1
        while j < n and not a[j]:
            j += 1
        sol += ceil((j - i) / (k * 2 + 1))
        i = j
    else: i += 1
print(sol)
#Verdict Execution timeMemoryGrader output
Fetching results...