結果

問題 No.417 チューリップバブル
ユーザー shinichishinichi
提出日時 2023-01-29 11:22:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 628 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 82,540 KB
最終ジャッジ日時 2023-09-11 19:44:46
合計ジャッジ時間 15,063 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,352 KB
testcase_01 AC 83 ms
76,020 KB
testcase_02 AC 83 ms
76,176 KB
testcase_03 AC 83 ms
76,068 KB
testcase_04 AC 77 ms
75,460 KB
testcase_05 AC 77 ms
75,420 KB
testcase_06 AC 83 ms
76,020 KB
testcase_07 AC 81 ms
75,764 KB
testcase_08 AC 169 ms
76,596 KB
testcase_09 AC 297 ms
76,924 KB
testcase_10 AC 379 ms
76,940 KB
testcase_11 AC 651 ms
77,296 KB
testcase_12 AC 1,417 ms
76,896 KB
testcase_13 AC 326 ms
76,920 KB
testcase_14 TLE -
testcase_15 AC 145 ms
76,820 KB
testcase_16 AC 147 ms
76,924 KB
testcase_17 AC 544 ms
77,536 KB
testcase_18 AC 542 ms
77,348 KB
testcase_19 AC 538 ms
77,352 KB
testcase_20 AC 1,868 ms
78,144 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 #

N, M = map(int, input().split())
U = [int(input()) for _ in range(N)]
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))

# 使用した時間を入れる
dp = [[U[i]] * (M + 1) for i in range(N)]


def dfs(v, p=-1):
    for nv, nw in tree[v]:
        if nv == p:
            continue
        dfs(nv, v)
        for m1 in range(M, -1, -1):
            for m2 in range(M-m1+1):
                t = m1 + 2*nw + m2
                if t <= M:
                    dp[v][t] = max(dp[v][t], dp[v][m1] + dp[nv][m2])

dfs(0)
print(max(dp[0]))
0