create dev channel

This commit is contained in:
2025-05-07 04:44:30 +09:00
parent 603fca2b20
commit 16a8e59450
426 changed files with 643 additions and 36 deletions

37
zeta/py/completed/1005.py Normal file
View File

@@ -0,0 +1,37 @@
import sys
import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.setrecursionlimit(1000000)
Mem: list
D: list
E: list
def get_time(now):
if Mem[now] != -1:
return Mem[now]
elif not E[now]:
Mem[now] = D[now]
return D[now]
else:
s = max([get_time(target) for target in E[now]]) + D[now]
Mem[now] = s
return s
if __name__ == "__main__":
T = int(input())
for _ in range(T):
N, K = map(int, input().split())
D = [0] + list(map(int, input().split()))
E = [[] for _ in range(N + 1)]
for _ in range(K):
u, v = map(int, input().split())
E[v].append(u)
W = int(input())
Mem = [-1] * (N + 1)
print(get_time(W))