結果

問題 No.417 チューリップバブル
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-30 09:48:41
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 77,228 KB
最終ジャッジ日時 2023-09-10 08:19:33
合計ジャッジ時間 5,851 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,300 KB
testcase_01 AC 71 ms
71,316 KB
testcase_02 AC 70 ms
71,352 KB
testcase_03 AC 71 ms
71,528 KB
testcase_04 AC 75 ms
71,420 KB
testcase_05 AC 72 ms
71,472 KB
testcase_06 AC 69 ms
71,452 KB
testcase_07 AC 70 ms
71,432 KB
testcase_08 AC 71 ms
71,416 KB
testcase_09 AC 76 ms
75,968 KB
testcase_10 AC 84 ms
76,212 KB
testcase_11 AC 82 ms
76,136 KB
testcase_12 AC 82 ms
76,272 KB
testcase_13 AC 85 ms
76,060 KB
testcase_14 AC 91 ms
76,204 KB
testcase_15 AC 83 ms
76,456 KB
testcase_16 AC 83 ms
76,484 KB
testcase_17 AC 93 ms
76,148 KB
testcase_18 AC 93 ms
76,248 KB
testcase_19 AC 88 ms
76,152 KB
testcase_20 AC 95 ms
76,232 KB
testcase_21 AC 100 ms
76,108 KB
testcase_22 AC 101 ms
76,032 KB
testcase_23 AC 109 ms
76,812 KB
testcase_24 AC 73 ms
71,356 KB
testcase_25 AC 102 ms
76,128 KB
testcase_26 AC 86 ms
76,148 KB
testcase_27 AC 90 ms
76,032 KB
testcase_28 AC 116 ms
76,792 KB
testcase_29 AC 107 ms
76,832 KB
testcase_30 AC 95 ms
76,208 KB
testcase_31 AC 110 ms
76,804 KB
testcase_32 AC 69 ms
71,352 KB
testcase_33 AC 70 ms
71,348 KB
testcase_34 AC 75 ms
75,552 KB
testcase_35 AC 130 ms
77,228 KB
testcase_36 AC 108 ms
76,816 KB
testcase_37 AC 104 ms
76,784 KB
testcase_38 AC 112 ms
76,980 KB
testcase_39 AC 98 ms
76,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
def dfs(u, p):
    cur = {0 : U[u]}
    for v, c in G[u]:
        if v == p:
            continue
        nxt = list(dfs(v, u).items())
        for t1, x in list(cur.items()):
            for t2, y in nxt:
                t = t1+t2+c*2
                if t <= m:
                    cur[t] = max(cur.get(t, 0), x+y)
    return cur
print(max(dfs(0, 0).values()))
0