2376 | 2023-01-11 23:04:54 | kristof | Karácsonyi égők | python3 | Accepted 100/100 | 347ms | 60080 KiB |
N, C = map(int, input().strip().split())
L = list(map(int, input().strip().split()))
minTav = N
nyilvantartoLista = [0 for i in range(C+1)]
mostTav = 0
mostTavRovidites = 0
benneVanSzam = 0
for i in range(N):
while mostTav < N and benneVanSzam < C:
if nyilvantartoLista[L[mostTav]] == 0:
benneVanSzam += 1
nyilvantartoLista[L[mostTav]] += 1
mostTav += 1
if benneVanSzam == C:
minTav = min(minTav, mostTav - mostTavRovidites)
while mostTavRovidites < mostTav and benneVanSzam == C:
nyilvantartoLista[L[mostTavRovidites]] -= 1
if nyilvantartoLista[L[mostTavRovidites]] == 0:
benneVanSzam -= 1
mostTavRovidites += 1
if benneVanSzam == C:
minTav = min(minTav, mostTav - mostTavRovidites)
print(minTav)
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 17ms | 11952 KiB | ||||
2 | Accepted | 17ms | 12232 KiB | ||||
subtask2 | 15/15 | ||||||
3 | Accepted | 261ms | 18752 KiB | ||||
4 | Accepted | 270ms | 19004 KiB | ||||
5 | Accepted | 263ms | 19136 KiB | ||||
6 | Accepted | 17ms | 12472 KiB | ||||
7 | Accepted | 17ms | 12976 KiB | ||||
subtask3 | 10/10 | ||||||
8 | Accepted | 17ms | 12872 KiB | ||||
9 | Accepted | 17ms | 12984 KiB | ||||
10 | Accepted | 17ms | 13228 KiB | ||||
11 | Accepted | 17ms | 13200 KiB | ||||
12 | Accepted | 17ms | 13336 KiB | ||||
subtask4 | 20/20 | ||||||
13 | Accepted | 17ms | 13596 KiB | ||||
14 | Accepted | 17ms | 13712 KiB | ||||
15 | Accepted | 17ms | 13780 KiB | ||||
16 | Accepted | 17ms | 13972 KiB | ||||
17 | Accepted | 17ms | 14140 KiB | ||||
subtask5 | 25/25 | ||||||
18 | Accepted | 21ms | 15380 KiB | ||||
19 | Accepted | 24ms | 15220 KiB | ||||
20 | Accepted | 23ms | 15100 KiB | ||||
21 | Accepted | 25ms | 14904 KiB | ||||
22 | Accepted | 24ms | 14400 KiB | ||||
subtask6 | 30/30 | ||||||
23 | Accepted | 246ms | 58040 KiB | ||||
24 | Accepted | 223ms | 52120 KiB | ||||
25 | Accepted | 224ms | 57820 KiB | ||||
26 | Accepted | 243ms | 60008 KiB | ||||
27 | Accepted | 231ms | 60080 KiB | ||||
28 | Accepted | 216ms | 57888 KiB | ||||
29 | Accepted | 347ms | 53092 KiB | ||||
30 | Accepted | 214ms | 21052 KiB |