8772 | 2024-01-29 18:22:59 | NagyLeo | Kutyavetélkedő | pypy3 | Hibás válasz 85/100 | 409ms | 190628 KiB |
def max_points(K, N, M, pairs):
can_do = [set() for i in range(K + 1)]
for a, b in pairs:
can_do[a].add(b)
current_points = [0] * (N + 2)
if T[N - 1] <= K:
current_points[N - 1] = 1
if T[N - 2] <= K:
current_points[N - 2] = 1
if T[N - 1] in can_do[T[N - 2]]:
current_points[N - 2] = 2
for i in range(N - 3, -1, -1):
if T[i] > K:
continue
if T[i + 1] in can_do[T[i]]:
current_points[i] = 1 + current_points[i + 1]
if T[i + 2] in can_do[T[i]]:
current_points[i] = max(current_points[i], 1 + current_points[i + 2])
return max(current_points[0], current_points[1])
N, K = map(int, input().split())
T = list(map(int, input().split()))
M = int(input())
pairs = [tuple(map(int, input().split())) for _ in range(M)]
print(max_points(K, N, M, pairs))
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Elfogadva | 41ms | 77032 KiB | ||||
2 | Elfogadva | 46ms | 76664 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Elfogadva | 50ms | 77104 KiB | ||||
4 | Elfogadva | 46ms | 77568 KiB | ||||
5 | Elfogadva | 43ms | 78156 KiB | ||||
6 | Elfogadva | 46ms | 78044 KiB | ||||
7 | Hibás válasz | 119ms | 144220 KiB | ||||
8 | Elfogadva | 118ms | 143812 KiB | ||||
9 | Elfogadva | 107ms | 144420 KiB | ||||
subtask3 | 19/19 | ||||||
10 | Elfogadva | 46ms | 78964 KiB | ||||
11 | Elfogadva | 43ms | 78648 KiB | ||||
12 | Elfogadva | 46ms | 78740 KiB | ||||
13 | Elfogadva | 48ms | 79076 KiB | ||||
14 | Elfogadva | 50ms | 78912 KiB | ||||
15 | Elfogadva | 48ms | 79304 KiB | ||||
16 | Elfogadva | 50ms | 79872 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Elfogadva | 101ms | 94004 KiB | ||||
18 | Elfogadva | 101ms | 94272 KiB | ||||
19 | Elfogadva | 108ms | 94308 KiB | ||||
20 | Elfogadva | 104ms | 95332 KiB | ||||
21 | Elfogadva | 103ms | 95852 KiB | ||||
22 | Elfogadva | 112ms | 96268 KiB | ||||
subtask5 | 32/32 | ||||||
23 | Elfogadva | 223ms | 123380 KiB | ||||
24 | Elfogadva | 226ms | 127524 KiB | ||||
25 | Elfogadva | 244ms | 133992 KiB | ||||
26 | Elfogadva | 230ms | 138096 KiB | ||||
27 | Elfogadva | 250ms | 138288 KiB | ||||
28 | Elfogadva | 300ms | 150528 KiB | ||||
29 | Elfogadva | 402ms | 190628 KiB | ||||
30 | Elfogadva | 409ms | 190484 KiB | ||||
31 | Elfogadva | 266ms | 159512 KiB | ||||
32 | Elfogadva | 190ms | 138204 KiB | ||||
33 | Elfogadva | 307ms | 176680 KiB | ||||
34 | Elfogadva | 307ms | 176372 KiB |