8771 | 2024-01-29 18:13:20 | NagyLeo | Kutyavetélkedő | python3 | Hibás válasz 85/100 | 694ms | 155168 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 | 17ms | 11444 KiB | ||||
2 | Elfogadva | 18ms | 11800 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Elfogadva | 18ms | 11952 KiB | ||||
4 | Elfogadva | 17ms | 11616 KiB | ||||
5 | Elfogadva | 17ms | 12236 KiB | ||||
6 | Elfogadva | 17ms | 12176 KiB | ||||
7 | Hibás válasz | 172ms | 26896 KiB | ||||
8 | Elfogadva | 171ms | 26976 KiB | ||||
9 | Elfogadva | 174ms | 27148 KiB | ||||
subtask3 | 19/19 | ||||||
10 | Elfogadva | 17ms | 12832 KiB | ||||
11 | Elfogadva | 17ms | 13248 KiB | ||||
12 | Elfogadva | 17ms | 13148 KiB | ||||
13 | Elfogadva | 17ms | 13228 KiB | ||||
14 | Elfogadva | 17ms | 13188 KiB | ||||
15 | Elfogadva | 17ms | 13340 KiB | ||||
16 | Elfogadva | 17ms | 13520 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Elfogadva | 23ms | 14136 KiB | ||||
18 | Elfogadva | 28ms | 14732 KiB | ||||
19 | Elfogadva | 35ms | 16476 KiB | ||||
20 | Elfogadva | 37ms | 16644 KiB | ||||
21 | Elfogadva | 43ms | 17844 KiB | ||||
22 | Elfogadva | 43ms | 18484 KiB | ||||
subtask5 | 32/32 | ||||||
23 | Elfogadva | 261ms | 57224 KiB | ||||
24 | Elfogadva | 286ms | 66052 KiB | ||||
25 | Elfogadva | 317ms | 71136 KiB | ||||
26 | Elfogadva | 321ms | 76472 KiB | ||||
27 | Elfogadva | 330ms | 84120 KiB | ||||
28 | Elfogadva | 526ms | 88196 KiB | ||||
29 | Elfogadva | 694ms | 155168 KiB | ||||
30 | Elfogadva | 675ms | 155160 KiB | ||||
31 | Elfogadva | 458ms | 97580 KiB | ||||
32 | Elfogadva | 314ms | 54496 KiB | ||||
33 | Elfogadva | 561ms | 137648 KiB | ||||
34 | Elfogadva | 560ms | 137568 KiB |