結果

問題 No.417 チューリップバブル
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-01 14:38:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 86,476 KB
実行使用メモリ 82,192 KB
最終ジャッジ日時 2023-09-08 11:28:17
合計ジャッジ時間 14,581 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 80 ms
75,396 KB
testcase_02 WA -
testcase_03 AC 80 ms
75,684 KB
testcase_04 AC 76 ms
74,612 KB
testcase_05 AC 78 ms
75,000 KB
testcase_06 WA -
testcase_07 AC 83 ms
75,840 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
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)[::-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