結果
問題 |
No.417 チューリップバブル
|
ユーザー |
|
提出日時 | 2023-01-31 14:10:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 535 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 82,464 KB |
実行使用メモリ | 85,480 KB |
最終ジャッジ日時 | 2024-06-30 17:30:07 |
合計ジャッジ時間 | 25,381 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 TLE * 1 -- * 4 |
ソースコード
N, M = map(int, input().split()) U = [int(input()) for _ in range(N)] G = [[] for _ in range(N)] for _ in range(N-1): A,B,C = map(int, input().split()) G[A].append((B, C)) G[B].append((A, C)) dp = [[U[i]]*(M+1) for i in range(N)] def dfs(x, par=-1): for nx, t in G[x]: if nx==par: continue dfs(nx, x) for m in range(M+1)[::-1]: for mm in range(M-m+1-2*t): T = m+mm+2*t dp[x][T] = max(dp[x][T], dp[x][m]+dp[nx][mm]) dfs(0) print(max(dp[0]))