27582023-01-21 17:36:10rennKarácsonyi égőkpython3Accepted 100/1001.149s62396 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)

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

        while szinek[egok[0]] > 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
1Accepted18ms11284 KiB
2Accepted17ms11856 KiB
subtask215/15
3Accepted119ms16480 KiB
4Accepted149ms16856 KiB
5Accepted159ms16916 KiB
6Accepted17ms12668 KiB
7Accepted17ms12588 KiB
subtask310/10
8Accepted17ms12500 KiB
9Accepted17ms12640 KiB
10Accepted17ms12860 KiB
11Accepted17ms13120 KiB
12Accepted17ms13292 KiB
subtask420/20
13Accepted17ms13380 KiB
14Accepted17ms13536 KiB
15Accepted17ms13780 KiB
16Accepted17ms14152 KiB
17Accepted17ms14232 KiB
subtask525/25
18Accepted19ms15240 KiB
19Accepted20ms14872 KiB
20Accepted18ms14960 KiB
21Accepted21ms14504 KiB
22Accepted20ms14136 KiB
subtask630/30
23Accepted179ms60968 KiB
24Accepted107ms45692 KiB
25Accepted195ms56992 KiB
26Accepted1.149s56312 KiB
27Accepted241ms62396 KiB
28Accepted203ms56072 KiB
29Accepted252ms45296 KiB
30Accepted146ms21400 KiB