結果

問題 No.417 チューリップバブル
ユーザー convexineqconvexineq
提出日時 2021-02-03 01:31:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 680 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 78,732 KB
最終ジャッジ日時 2023-09-12 11:34:19
合計ジャッジ時間 28,814 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,024 KB
testcase_01 AC 83 ms
75,940 KB
testcase_02 AC 88 ms
76,044 KB
testcase_03 AC 82 ms
75,664 KB
testcase_04 AC 75 ms
71,300 KB
testcase_05 AC 74 ms
71,164 KB
testcase_06 AC 94 ms
76,572 KB
testcase_07 AC 91 ms
76,488 KB
testcase_08 AC 120 ms
76,164 KB
testcase_09 AC 175 ms
76,288 KB
testcase_10 AC 196 ms
76,180 KB
testcase_11 AC 596 ms
76,544 KB
testcase_12 AC 587 ms
76,256 KB
testcase_13 AC 272 ms
76,196 KB
testcase_14 AC 901 ms
77,492 KB
testcase_15 AC 140 ms
76,176 KB
testcase_16 AC 143 ms
75,944 KB
testcase_17 AC 518 ms
77,664 KB
testcase_18 AC 519 ms
77,728 KB
testcase_19 AC 517 ms
77,284 KB
testcase_20 AC 1,785 ms
78,360 KB
testcase_21 AC 1,775 ms
78,492 KB
testcase_22 AC 1,779 ms
78,528 KB
testcase_23 AC 1,777 ms
78,472 KB
testcase_24 AC 82 ms
75,808 KB
testcase_25 AC 1,783 ms
78,084 KB
testcase_26 AC 233 ms
76,136 KB
testcase_27 AC 1,267 ms
77,820 KB
testcase_28 AC 1,763 ms
78,604 KB
testcase_29 AC 1,760 ms
78,292 KB
testcase_30 AC 1,768 ms
78,476 KB
testcase_31 AC 1,761 ms
78,732 KB
testcase_32 AC 78 ms
75,692 KB
testcase_33 AC 129 ms
76,248 KB
testcase_34 AC 418 ms
76,036 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)

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 = [[0]*(m+1) for _ in range(n)]
for i in order[n-1:0:-1]:
    for j in range(m+1): dp[i][j] += U[i]
    merge(i,parent[i],dist[i])
print(max(dp[0])+U[0])
0