27562023-01-21 17:30:10rennKarácsonyi égőkpython3Wrong answer 0/100351ms60860 KiB
sor = input().split()
N = int(sor[0])
C = int(sor[1])

sor = input().split()


def megold():
    egok = []
    szinek = [0 for i in range(0, C)]
    global Y
    global Z
    Y = 0
    Z = 0

    for X in range(0, C):
        Y = int(sor[X])

        szinek[Y] += 1
        egok.append(Y)

        if szinek[Y] == 1:
            Z += 1

    if Z == C:
        print(C)
        return

    for X in range(C, N):
        Y = int(sor[X])
        egok.append(Y)

        if egok[0] == egok[-1]:
            egok.pop(0)
            continue

        szinek[Y] += 1
        if szinek[Y] == 1:
            Z += 1

        while egok[0] == egok[1]:
            szinek[egok[0]] -= 1
            if szinek[egok[0]] == 0:
                Z -= 1
            egok.pop(0)

        if Z == C:
            print(len(egok))
            return


megold()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted17ms10952 KiB
2Accepted17ms11428 KiB
subtask20/15
3Wrong answer277ms15520 KiB
4Wrong answer319ms16308 KiB
5Wrong answer351ms16504 KiB
6Wrong answer17ms12284 KiB
7Wrong answer17ms12340 KiB
subtask30/10
8Accepted17ms12488 KiB
9Wrong answer17ms12664 KiB
10Wrong answer17ms13100 KiB
11Wrong answer17ms12984 KiB
12Wrong answer17ms12972 KiB
subtask40/20
13Wrong answer17ms13080 KiB
14Wrong answer17ms13040 KiB
15Wrong answer17ms13504 KiB
16Accepted17ms13460 KiB
17Wrong answer17ms13236 KiB
subtask50/25
18Accepted20ms14960 KiB
19Wrong answer19ms14796 KiB
20Wrong answer18ms14704 KiB
21Wrong answer20ms14384 KiB
22Wrong answer19ms14344 KiB
subtask60/30
23Accepted170ms60860 KiB
24Wrong answer108ms45872 KiB
25Wrong answer182ms57592 KiB
26Wrong answer155ms56172 KiB
27Wrong answer184ms59416 KiB
28Wrong answer179ms56356 KiB
29Wrong answer170ms51828 KiB
30Wrong answer172ms20496 KiB