2761 | 2023-01-21 22:23:15 | renn | Karácsonyi égők | python3 | Accepted 100/100 | 202ms | 59556 KiB |
N, C = map(int, input().strip().split())
szinek = list(map(int, input().strip().split()))
szindarab = [0 for i in range(0, C)]
K = 0
M = N
L = 0
for i in range(0, N):
if szindarab[szinek[i]] == 0:
K += 1
szindarab[szinek[i]] += 1
if K != C:
continue
while K == C:
szindarab[szinek[L]] -= 1
if szindarab[szinek[L]] == 0:
K -= 1
L += 1
M = min(M, i - L)
print(M + 2)
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 17ms | 11164 KiB | ||||
2 | Accepted | 17ms | 11400 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 163ms | 19944 KiB | ||||
4 | Accepted | 165ms | 19768 KiB | ||||
5 | Accepted | 162ms | 19976 KiB | ||||
6 | Accepted | 17ms | 11792 KiB | ||||
7 | Accepted | 17ms | 12132 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 17ms | 12388 KiB | ||||
9 | Accepted | 17ms | 12700 KiB | ||||
10 | Accepted | 17ms | 12688 KiB | ||||
11 | Accepted | 17ms | 12624 KiB | ||||
12 | Accepted | 17ms | 13056 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 17ms | 12704 KiB | ||||
14 | Accepted | 17ms | 12924 KiB | ||||
15 | Accepted | 17ms | 13160 KiB | ||||
16 | Accepted | 17ms | 13080 KiB | ||||
17 | Accepted | 17ms | 12948 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 19ms | 14384 KiB | ||||
19 | Accepted | 19ms | 14428 KiB | ||||
20 | Accepted | 19ms | 14480 KiB | ||||
21 | Accepted | 20ms | 14180 KiB | ||||
22 | Accepted | 19ms | 13692 KiB | ||||
subtask6 | 30/30 | ||||||
23 | Accepted | 172ms | 57208 KiB | ||||
24 | Accepted | 150ms | 52124 KiB | ||||
25 | Accepted | 157ms | 57364 KiB | ||||
26 | Accepted | 157ms | 59244 KiB | ||||
27 | Accepted | 158ms | 59556 KiB | ||||
28 | Accepted | 148ms | 57128 KiB | ||||
29 | Accepted | 202ms | 52248 KiB | ||||
30 | Accepted | 130ms | 21848 KiB |