結果

問題 No.417 チューリップバブル
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-01 12:54:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 593 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 86,648 KB
実行使用メモリ 80,104 KB
最終ジャッジ日時 2023-09-08 11:24:30
合計ジャッジ時間 30,195 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
80,104 KB
testcase_01 AC 82 ms
75,744 KB
testcase_02 AC 81 ms
75,664 KB
testcase_03 AC 80 ms
75,804 KB
testcase_04 AC 72 ms
71,064 KB
testcase_05 AC 72 ms
70,948 KB
testcase_06 AC 84 ms
75,692 KB
testcase_07 AC 81 ms
75,932 KB
testcase_08 AC 120 ms
75,760 KB
testcase_09 AC 175 ms
75,932 KB
testcase_10 AC 200 ms
75,692 KB
testcase_11 AC 627 ms
75,856 KB
testcase_12 AC 621 ms
75,728 KB
testcase_13 AC 283 ms
75,760 KB
testcase_14 AC 959 ms
75,888 KB
testcase_15 AC 138 ms
75,832 KB
testcase_16 AC 140 ms
75,828 KB
testcase_17 AC 540 ms
75,860 KB
testcase_18 AC 547 ms
75,708 KB
testcase_19 AC 549 ms
75,872 KB
testcase_20 AC 1,925 ms
77,788 KB
testcase_21 AC 1,907 ms
78,228 KB
testcase_22 AC 1,904 ms
77,836 KB
testcase_23 AC 1,910 ms
77,836 KB
testcase_24 AC 83 ms
75,944 KB
testcase_25 AC 1,915 ms
78,156 KB
testcase_26 AC 245 ms
75,644 KB
testcase_27 AC 1,356 ms
77,488 KB
testcase_28 AC 1,901 ms
77,788 KB
testcase_29 AC 1,892 ms
77,964 KB
testcase_30 AC 1,911 ms
78,156 KB
testcase_31 AC 1,897 ms
77,992 KB
testcase_32 AC 81 ms
75,936 KB
testcase_33 AC 134 ms
75,872 KB
testcase_34 AC 449 ms
75,752 KB
testcase_35 TLE -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
u = [int(input()) for _ in range(n)]
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))
dp = [[0]*(m+1) for _ in range(n)]
def dfs(i, parent):
    for j, cost in graph[i]:
        if j == parent:
            continue
        dfs(j, i)
        for k in range(m+1)[::-1]:
            for l in range(cost*2, k+1)[::-1]:
                dp[i][k] = max(dp[i][k], dp[i][k-l]+dp[j][l-cost*2])
    for j in range(m+1):
        dp[i][j] += u[i]
dfs(0, 0)
print(max(dp[0]))
0