8770 | 2024-01-29 18:11:25 | NagyLeo | Kutyavetélkedő | pypy3 | Wrong answer 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))
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 48ms | 76716 KiB | ||||
2 | Accepted | 45ms | 77112 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Accepted | 46ms | 77036 KiB | ||||
4 | Accepted | 43ms | 77376 KiB | ||||
5 | Accepted | 39ms | 77988 KiB | ||||
6 | Accepted | 46ms | 77988 KiB | ||||
7 | Wrong answer | 122ms | 143516 KiB | ||||
8 | Accepted | 123ms | 144576 KiB | ||||
9 | Accepted | 109ms | 144228 KiB | ||||
subtask3 | 19/19 | ||||||
10 | Accepted | 39ms | 79036 KiB | ||||
11 | Accepted | 39ms | 79448 KiB | ||||
12 | Accepted | 46ms | 78940 KiB | ||||
13 | Accepted | 46ms | 79104 KiB | ||||
14 | Accepted | 43ms | 79280 KiB | ||||
15 | Accepted | 46ms | 79056 KiB | ||||
16 | Accepted | 45ms | 79992 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Accepted | 92ms | 94036 KiB | ||||
18 | Accepted | 98ms | 93916 KiB | ||||
19 | Accepted | 98ms | 94040 KiB | ||||
20 | Accepted | 100ms | 94720 KiB | ||||
21 | Accepted | 103ms | 95224 KiB | ||||
22 | Accepted | 104ms | 94892 KiB | ||||
subtask5 | 32/32 | ||||||
23 | Accepted | 223ms | 123792 KiB | ||||
24 | Accepted | 232ms | 131756 KiB | ||||
25 | Accepted | 232ms | 137176 KiB | ||||
26 | Accepted | 240ms | 141744 KiB | ||||
27 | Accepted | 245ms | 149868 KiB | ||||
28 | Accepted | 312ms | 148340 KiB | ||||
29 | Accepted | 451ms | 201724 KiB | ||||
30 | Accepted | 458ms | 200940 KiB | ||||
31 | Accepted | 291ms | 169368 KiB | ||||
32 | Accepted | 197ms | 137448 KiB | ||||
33 | Accepted | 344ms | 187880 KiB | ||||
34 | Accepted | 338ms | 189888 KiB |