23532023-01-10 22:43:31kristofKarácsonyi égőkpython3Wrong answer 70/100321ms60120 KiB
N, C = map(int, input().strip().split())
L = list(map(int, input().strip().split()))

minTav = 2e5
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)


SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted17ms11248 KiB
2Accepted17ms11676 KiB
subtask215/15
3Accepted282ms18336 KiB
4Accepted263ms18376 KiB
5Accepted277ms18568 KiB
6Accepted17ms12272 KiB
7Accepted17ms12692 KiB
subtask310/10
8Accepted17ms12508 KiB
9Accepted17ms12628 KiB
10Accepted17ms12732 KiB
11Accepted17ms12960 KiB
12Accepted16ms12880 KiB
subtask420/20
13Accepted17ms13332 KiB
14Accepted17ms13364 KiB
15Accepted17ms13460 KiB
16Accepted17ms13908 KiB
17Accepted17ms13516 KiB
subtask525/25
18Accepted23ms14644 KiB
19Accepted24ms14620 KiB
20Accepted24ms14644 KiB
21Accepted25ms14524 KiB
22Accepted24ms14348 KiB
subtask60/30
23Wrong answer244ms58024 KiB
24Accepted209ms52752 KiB
25Accepted232ms57944 KiB
26Accepted237ms60120 KiB
27Accepted228ms60108 KiB
28Accepted224ms57740 KiB
29Accepted321ms52744 KiB
30Accepted216ms20800 KiB