結果

問題 No.417 チューリップバブル
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-01 14:23:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 13,356 KB
最終ジャッジ日時 2023-09-08 11:27:30
合計ジャッジ時間 6,229 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 22 ms
7,792 KB
testcase_02 WA -
testcase_03 AC 21 ms
7,780 KB
testcase_04 AC 16 ms
7,980 KB
testcase_05 AC 16 ms
7,836 KB
testcase_06 WA -
testcase_07 AC 31 ms
7,780 KB
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
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)]
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(m+1):
                if k<l+cost*2:
                    continue
                dp[i][k] = max(dp[i][k], dp[j][l])
    for j in range(m+1):
        dp[i][j] += u[i]
dfs(0, 0)
print(max(dp[0]))
0