27572023-01-21 17:33:32rennKarácsonyi égőkpython3Wrong answer 0/1001.572s60380 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] > 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
1Wrong answer17ms11204 KiB
2Wrong answer17ms11280 KiB
subtask20/15
3Wrong answer328ms15764 KiB
4Wrong answer736ms16116 KiB
5Wrong answer345ms16508 KiB
6Wrong answer17ms12228 KiB
7Wrong answer17ms12408 KiB
subtask30/10
8Accepted17ms12604 KiB
9Wrong answer17ms12212 KiB
10Wrong answer17ms12648 KiB
11Accepted17ms12816 KiB
12Wrong answer17ms12660 KiB
subtask40/20
13Wrong answer17ms12804 KiB
14Wrong answer17ms12976 KiB
15Wrong answer17ms12884 KiB
16Wrong answer17ms12864 KiB
17Wrong answer17ms12968 KiB
subtask50/25
18Accepted21ms14300 KiB
19Runtime error18ms13900 KiB
20Runtime error17ms13928 KiB
21Wrong answer21ms14020 KiB
22Wrong answer19ms13652 KiB
subtask60/30
23Accepted180ms60380 KiB
24Wrong answer1.199s45452 KiB
25Wrong answer1.202s51140 KiB
26Wrong answer305ms54564 KiB
27Time limit exceeded1.572s26548 KiB
28Runtime error50ms44828 KiB
29Wrong answer1.001s45960 KiB
30Wrong answer171ms20052 KiB