답안 #143579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143579 2019-08-14T16:25:10 Z tnbs10 Rasvjeta (COCI17_rasvjeta) Python 3
50 / 50
29 ms 3420 KB
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)
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3300 KB Output is correct
2 Correct 25 ms 3300 KB Output is correct
3 Correct 26 ms 3380 KB Output is correct
4 Correct 27 ms 3300 KB Output is correct
5 Correct 27 ms 3420 KB Output is correct
6 Correct 26 ms 3300 KB Output is correct
7 Correct 26 ms 3300 KB Output is correct
8 Correct 28 ms 3380 KB Output is correct
9 Correct 29 ms 3380 KB Output is correct
10 Correct 28 ms 3300 KB Output is correct