8774 | 2024-01-29 18:30:07 | NagyLeo | Kutyavetélkedő | pypy3 | Hibás válasz 85/100 | 411ms | 190828 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
current_points[i] = 1
if T[i + 1] in can_do[T[i]]:
current_points[i] = max(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 | 77052 KiB | ||||
2 | Hibás válasz | 39ms | 76868 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Elfogadva | 41ms | 77196 KiB | ||||
4 | Elfogadva | 39ms | 77452 KiB | ||||
5 | Elfogadva | 46ms | 77540 KiB | ||||
6 | Elfogadva | 43ms | 78164 KiB | ||||
7 | Hibás válasz | 104ms | 143864 KiB | ||||
8 | Elfogadva | 103ms | 144032 KiB | ||||
9 | Elfogadva | 119ms | 144416 KiB | ||||
subtask3 | 19/19 | ||||||
10 | Elfogadva | 43ms | 78636 KiB | ||||
11 | Elfogadva | 46ms | 78844 KiB | ||||
12 | Elfogadva | 43ms | 79156 KiB | ||||
13 | Elfogadva | 39ms | 79556 KiB | ||||
14 | Elfogadva | 39ms | 79580 KiB | ||||
15 | Elfogadva | 50ms | 79440 KiB | ||||
16 | Elfogadva | 48ms | 80480 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Elfogadva | 103ms | 94300 KiB | ||||
18 | Elfogadva | 108ms | 94304 KiB | ||||
19 | Elfogadva | 120ms | 94740 KiB | ||||
20 | Elfogadva | 112ms | 95360 KiB | ||||
21 | Elfogadva | 112ms | 95980 KiB | ||||
22 | Elfogadva | 114ms | 95960 KiB | ||||
subtask5 | 32/32 | ||||||
23 | Elfogadva | 224ms | 122512 KiB | ||||
24 | Elfogadva | 211ms | 127816 KiB | ||||
25 | Elfogadva | 240ms | 134412 KiB | ||||
26 | Elfogadva | 252ms | 137912 KiB | ||||
27 | Elfogadva | 250ms | 138184 KiB | ||||
28 | Elfogadva | 303ms | 150616 KiB | ||||
29 | Elfogadva | 404ms | 190692 KiB | ||||
30 | Elfogadva | 411ms | 190828 KiB | ||||
31 | Elfogadva | 268ms | 159224 KiB | ||||
32 | Elfogadva | 210ms | 138136 KiB | ||||
33 | Elfogadva | 351ms | 176312 KiB | ||||
34 | Elfogadva | 351ms | 176052 KiB |