96982024-03-01 07:33:59birozsSzínes szobák (50 pont)python3Time limit exceeded 8/50400ms22252 KiB
#be = open("in.2")
N,K,M = map(int,input().split())
szin = list(map(int,input().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,input().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
base8/50
1Accepted0/017ms11352 KiB
2Time limit exceeded0/0375ms20576 KiB
3Accepted1/1201ms12044 KiB
4Accepted1/1187ms12264 KiB
5Accepted1/1199ms12380 KiB
6Accepted1/1177ms12412 KiB
7Accepted1/1201ms12564 KiB
8Accepted1/1174ms12604 KiB
9Accepted1/1175ms12844 KiB
10Time limit exceeded0/1365ms5144 KiB
11Accepted1/1175ms13248 KiB
12Time limit exceeded0/1368ms5732 KiB
13Time limit exceeded0/1356ms6204 KiB
14Time limit exceeded0/1372ms6712 KiB
15Time limit exceeded0/1379ms7172 KiB
16Time limit exceeded0/1363ms7092 KiB
17Time limit exceeded0/1384ms7432 KiB
18Time limit exceeded0/1388ms7496 KiB
19Time limit exceeded0/1384ms17608 KiB
20Time limit exceeded0/1384ms17432 KiB
21Time limit exceeded0/1363ms17400 KiB
22Time limit exceeded0/1377ms17300 KiB
23Time limit exceeded0/1368ms17460 KiB
24Time limit exceeded0/1381ms17756 KiB
25Time limit exceeded0/1400ms17648 KiB
26Time limit exceeded0/1377ms17544 KiB
27Time limit exceeded0/3388ms21700 KiB
28Time limit exceeded0/3361ms21868 KiB
29Time limit exceeded0/3368ms21888 KiB
30Time limit exceeded0/3368ms22068 KiB
31Time limit exceeded0/3381ms21976 KiB
32Time limit exceeded0/3377ms22252 KiB
33Time limit exceeded0/4379ms14572 KiB
34Time limit exceeded0/4368ms14756 KiB