結果

問題 No.417 チューリップバブル
ユーザー convexineqconvexineq
提出日時 2021-02-03 02:40:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,009 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 78,248 KB
最終ジャッジ日時 2023-09-12 11:43:25
合計ジャッジ時間 15,738 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
75,872 KB
testcase_01 AC 76 ms
75,176 KB
testcase_02 AC 77 ms
75,504 KB
testcase_03 AC 78 ms
75,488 KB
testcase_04 AC 71 ms
71,064 KB
testcase_05 AC 73 ms
71,244 KB
testcase_06 AC 80 ms
76,216 KB
testcase_07 AC 78 ms
75,792 KB
testcase_08 AC 90 ms
75,932 KB
testcase_09 AC 102 ms
76,072 KB
testcase_10 AC 111 ms
75,992 KB
testcase_11 AC 209 ms
76,036 KB
testcase_12 AC 208 ms
76,076 KB
testcase_13 AC 130 ms
75,944 KB
testcase_14 AC 287 ms
75,880 KB
testcase_15 AC 97 ms
76,052 KB
testcase_16 AC 97 ms
75,936 KB
testcase_17 AC 194 ms
76,112 KB
testcase_18 AC 193 ms
76,348 KB
testcase_19 AC 192 ms
75,992 KB
testcase_20 AC 513 ms
75,972 KB
testcase_21 AC 510 ms
76,048 KB
testcase_22 AC 514 ms
76,096 KB
testcase_23 AC 512 ms
75,996 KB
testcase_24 AC 75 ms
71,320 KB
testcase_25 AC 514 ms
75,936 KB
testcase_26 AC 122 ms
75,984 KB
testcase_27 AC 381 ms
75,992 KB
testcase_28 AC 509 ms
76,116 KB
testcase_29 AC 507 ms
75,764 KB
testcase_30 AC 509 ms
76,060 KB
testcase_31 AC 506 ms
75,988 KB
testcase_32 AC 71 ms
71,032 KB
testcase_33 AC 93 ms
75,888 KB
testcase_34 AC 166 ms
75,896 KB
testcase_35 AC 974 ms
78,248 KB
testcase_36 AC 961 ms
78,200 KB
testcase_37 AC 1,009 ms
78,192 KB
testcase_38 AC 984 ms
78,212 KB
testcase_39 AC 988 ms
77,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
m //= 2
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] = c
        parent[u] = v
        order.append(u)

def merge(v,p,d):
    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])

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