Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created June 14, 2022 06:38
Show Gist options
  • Save mym0404/82a2bca6078451b360805762c63f5d9f to your computer and use it in GitHub Desktop.
Save mym0404/82a2bca6078451b360805762c63f5d9f to your computer and use it in GitHub Desktop.
n, k, b = map(int, input().split())
active = [1 for _ in range(n + 1)]
for i in range(b):
broken = int(input())
active[broken] = 0
active[0] = 0
answer = 10 ** 9
for i in range(1, n + 1):
active[i] += active[i - 1]
for i in range(k, n + 1):
current_active = active[i] - active[i - k]
answer = min(answer, k - current_active)
print(answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment