8770 | 2024-01-29 18:11:25 | NagyLeo | Kutyavetélkedő | pypy3 | Hibás válasz 85/100 | 458ms | 201724 KiB |
def max_points(K, N, M, pairs):
tricks = set(range(1, K + 1))
can_do = {i: set() for i in range(1, 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 | 48ms | 76716 KiB | ||||
2 | Elfogadva | 45ms | 77112 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Elfogadva | 46ms | 77036 KiB | ||||
4 | Elfogadva | 43ms | 77376 KiB | ||||
5 | Elfogadva | 39ms | 77988 KiB | ||||
6 | Elfogadva | 46ms | 77988 KiB | ||||
7 | Hibás válasz | 122ms | 143516 KiB | ||||
8 | Elfogadva | 123ms | 144576 KiB | ||||
9 | Elfogadva | 109ms | 144228 KiB | ||||
subtask3 | 19/19 | ||||||
10 | Elfogadva | 39ms | 79036 KiB | ||||
11 | Elfogadva | 39ms | 79448 KiB | ||||
12 | Elfogadva | 46ms | 78940 KiB | ||||
13 | Elfogadva | 46ms | 79104 KiB | ||||
14 | Elfogadva | 43ms | 79280 KiB | ||||
15 | Elfogadva | 46ms | 79056 KiB | ||||
16 | Elfogadva | 45ms | 79992 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Elfogadva | 92ms | 94036 KiB | ||||
18 | Elfogadva | 98ms | 93916 KiB | ||||
19 | Elfogadva | 98ms | 94040 KiB | ||||
20 | Elfogadva | 100ms | 94720 KiB | ||||
21 | Elfogadva | 103ms | 95224 KiB | ||||
22 | Elfogadva | 104ms | 94892 KiB | ||||
subtask5 | 32/32 | ||||||
23 | Elfogadva | 223ms | 123792 KiB | ||||
24 | Elfogadva | 232ms | 131756 KiB | ||||
25 | Elfogadva | 232ms | 137176 KiB | ||||
26 | Elfogadva | 240ms | 141744 KiB | ||||
27 | Elfogadva | 245ms | 149868 KiB | ||||
28 | Elfogadva | 312ms | 148340 KiB | ||||
29 | Elfogadva | 451ms | 201724 KiB | ||||
30 | Elfogadva | 458ms | 200940 KiB | ||||
31 | Elfogadva | 291ms | 169368 KiB | ||||
32 | Elfogadva | 197ms | 137448 KiB | ||||
33 | Elfogadva | 344ms | 187880 KiB | ||||
34 | Elfogadva | 338ms | 189888 KiB |