96962024-03-01 07:29:48birozsSzínes szobák (50 pont)python3Runtime error 0/5018ms14324 KiB
be = open("in.2")
N,K,M = map(int,be.readline().split())
szin = list(map(int,be.readline().split()))
rend = []
for i in range(K+1):
    rend.append([])
for i in range(N):
    rend[szin[i]].append(i)
#print(rend)

szoba = [1] * (N + 2)
#print(szoba)
for i in range(1,M+1):
    AktSzin,Irany = map(int,be.readline().split())
    if Irany == 1:
        for j in range(len(rend[AktSzin])-1,-1,-1):
            szoba[rend[AktSzin][j]+2] += szoba[rend[AktSzin][j]+1]
            szoba[rend[AktSzin][j]+1] = 0
    else:
        for j in range(0,len(rend[AktSzin])):
                szoba[rend[AktSzin][j]] += szoba[rend[AktSzin][j]+1]
                szoba[rend[AktSzin][j]+1] = 0
    #print(szoba)
be.close()
print(N-sum(szoba[1:-1]))
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/017ms10980 KiB
2Runtime error0/017ms11424 KiB
3Runtime error0/117ms11628 KiB
4Runtime error0/117ms11576 KiB
5Runtime error0/117ms11752 KiB
6Runtime error0/118ms12164 KiB
7Runtime error0/117ms12120 KiB
8Runtime error0/118ms12536 KiB
9Runtime error0/117ms12696 KiB
10Runtime error0/117ms12664 KiB
11Runtime error0/117ms12532 KiB
12Runtime error0/118ms12624 KiB
13Runtime error0/117ms12640 KiB
14Runtime error0/117ms12588 KiB
15Runtime error0/118ms13048 KiB
16Runtime error0/117ms13296 KiB
17Runtime error0/117ms12948 KiB
18Runtime error0/117ms13236 KiB
19Runtime error0/117ms13136 KiB
20Runtime error0/117ms13316 KiB
21Runtime error0/118ms13572 KiB
22Runtime error0/117ms13684 KiB
23Runtime error0/117ms13448 KiB
24Runtime error0/117ms13624 KiB
25Runtime error0/117ms13812 KiB
26Runtime error0/117ms13752 KiB
27Runtime error0/317ms14040 KiB
28Runtime error0/317ms14048 KiB
29Runtime error0/317ms14288 KiB
30Runtime error0/317ms14044 KiB
31Runtime error0/317ms14032 KiB
32Runtime error0/317ms14324 KiB
33Runtime error0/418ms14232 KiB
34Runtime error0/417ms14080 KiB