8773 | 2024-01-29 18:23:30 | NagyLeo | Kutyavetélkedő | python3 | Hibás válasz 85/100 | 610ms | 124184 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 | 17ms | 11472 KiB | ||||
2 | Elfogadva | 18ms | 11684 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Elfogadva | 17ms | 11776 KiB | ||||
4 | Elfogadva | 17ms | 12000 KiB | ||||
5 | Elfogadva | 17ms | 12116 KiB | ||||
6 | Elfogadva | 17ms | 12208 KiB | ||||
7 | Hibás válasz | 175ms | 27092 KiB | ||||
8 | Elfogadva | 175ms | 27236 KiB | ||||
9 | Elfogadva | 168ms | 27184 KiB | ||||
subtask3 | 19/19 | ||||||
10 | Elfogadva | 18ms | 12684 KiB | ||||
11 | Elfogadva | 19ms | 13152 KiB | ||||
12 | Elfogadva | 18ms | 13260 KiB | ||||
13 | Elfogadva | 18ms | 13356 KiB | ||||
14 | Elfogadva | 17ms | 13344 KiB | ||||
15 | Elfogadva | 17ms | 13148 KiB | ||||
16 | Elfogadva | 17ms | 13308 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Elfogadva | 21ms | 14400 KiB | ||||
18 | Elfogadva | 28ms | 15132 KiB | ||||
19 | Elfogadva | 35ms | 16636 KiB | ||||
20 | Elfogadva | 35ms | 16736 KiB | ||||
21 | Elfogadva | 41ms | 17920 KiB | ||||
22 | Elfogadva | 41ms | 18292 KiB | ||||
subtask5 | 32/32 | ||||||
23 | Elfogadva | 250ms | 53912 KiB | ||||
24 | Elfogadva | 268ms | 57868 KiB | ||||
25 | Elfogadva | 291ms | 62600 KiB | ||||
26 | Elfogadva | 296ms | 64784 KiB | ||||
27 | Elfogadva | 296ms | 68848 KiB | ||||
28 | Elfogadva | 490ms | 86716 KiB | ||||
29 | Elfogadva | 610ms | 123864 KiB | ||||
30 | Elfogadva | 606ms | 124184 KiB | ||||
31 | Elfogadva | 456ms | 81428 KiB | ||||
32 | Elfogadva | 298ms | 51744 KiB | ||||
33 | Elfogadva | 507ms | 107344 KiB | ||||
34 | Elfogadva | 507ms | 106908 KiB |