結果

問題 No.417 チューリップバブル
ユーザー neko0774neko0774
提出日時 2023-01-31 13:51:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 641 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 78,440 KB
最終ジャッジ日時 2023-09-13 07:13:54
合計ジャッジ時間 15,819 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
76,220 KB
testcase_01 AC 77 ms
75,868 KB
testcase_02 AC 82 ms
76,240 KB
testcase_03 AC 77 ms
75,924 KB
testcase_04 AC 74 ms
75,452 KB
testcase_05 AC 71 ms
75,468 KB
testcase_06 AC 78 ms
76,332 KB
testcase_07 AC 78 ms
76,376 KB
testcase_08 AC 169 ms
76,792 KB
testcase_09 AC 307 ms
77,032 KB
testcase_10 AC 376 ms
76,984 KB
testcase_11 AC 652 ms
77,256 KB
testcase_12 AC 1,411 ms
77,008 KB
testcase_13 AC 322 ms
77,168 KB
testcase_14 TLE -
testcase_15 AC 139 ms
77,024 KB
testcase_16 AC 140 ms
77,060 KB
testcase_17 AC 537 ms
77,248 KB
testcase_18 AC 536 ms
77,540 KB
testcase_19 AC 537 ms
77,592 KB
testcase_20 AC 1,866 ms
78,440 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
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)]
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
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):
                T = m+mm+2*t
                if T<M+1: dp[x][T] = max(dp[x][T], dp[x][m]+dp[nx][mm])
dfs(0)
print(max(dp[0]))
0