結果

問題 No.417 チューリップバブル
ユーザー convexineqconvexineq
提出日時 2021-02-03 01:37:35
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 615 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 86,676 KB
実行使用メモリ 84,180 KB
最終ジャッジ日時 2023-09-12 11:36:43
合計ジャッジ時間 34,870 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,132 KB
testcase_01 AC 85 ms
75,852 KB
testcase_02 AC 83 ms
75,816 KB
testcase_03 AC 82 ms
75,884 KB
testcase_04 AC 74 ms
71,360 KB
testcase_05 AC 75 ms
71,440 KB
testcase_06 AC 89 ms
76,376 KB
testcase_07 AC 91 ms
76,008 KB
testcase_08 AC 130 ms
76,400 KB
testcase_09 AC 186 ms
76,412 KB
testcase_10 AC 219 ms
76,208 KB
testcase_11 AC 709 ms
76,576 KB
testcase_12 AC 708 ms
76,292 KB
testcase_13 AC 310 ms
76,172 KB
testcase_14 AC 1,110 ms
76,260 KB
testcase_15 AC 155 ms
76,324 KB
testcase_16 AC 151 ms
76,448 KB
testcase_17 AC 627 ms
76,376 KB
testcase_18 AC 623 ms
76,188 KB
testcase_19 AC 621 ms
76,112 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 81 ms
75,892 KB
testcase_25 TLE -
testcase_26 AC 264 ms
76,200 KB
testcase_27 AC 1,556 ms
78,012 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 76 ms
74,988 KB
testcase_33 AC 127 ms
76,612 KB
testcase_34 AC 500 ms
76,460 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)]
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))

dist = [0]*n
parent = [-1]*n
order = [0]
for v in order:
    for u,c in g[v]:
        if parent[v] == u: continue
        dist[u] = 2*c
        parent[u] = v
        order.append(u)

dp = [[U[i]]*(m+1) for i in range(n)]
for v in order[n-1:0:-1]:
    p,d = parent[v],dist[v]
    for i in range(m,d-1,-1):
        for k in range(i-d+1):
            dp[p][i] = max(dp[p][i],dp[p][i-k-d] + dp[v][k])

print(max(dp[0]))
0