結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,288 KB
testcase_01 AC 75 ms
75,444 KB
testcase_02 AC 77 ms
75,396 KB
testcase_03 AC 77 ms
75,400 KB
testcase_04 AC 73 ms
70,980 KB
testcase_05 AC 71 ms
71,244 KB
testcase_06 AC 79 ms
76,000 KB
testcase_07 AC 77 ms
75,888 KB
testcase_08 AC 85 ms
75,884 KB
testcase_09 AC 98 ms
75,952 KB
testcase_10 AC 106 ms
76,032 KB
testcase_11 AC 205 ms
76,072 KB
testcase_12 AC 204 ms
75,840 KB
testcase_13 AC 126 ms
76,080 KB
testcase_14 AC 281 ms
76,024 KB
testcase_15 AC 92 ms
75,904 KB
testcase_16 AC 93 ms
75,912 KB
testcase_17 AC 190 ms
75,908 KB
testcase_18 AC 190 ms
75,904 KB
testcase_19 AC 190 ms
75,888 KB
testcase_20 AC 511 ms
75,896 KB
testcase_21 AC 506 ms
75,900 KB
testcase_22 AC 512 ms
75,800 KB
testcase_23 AC 505 ms
75,948 KB
testcase_24 AC 74 ms
71,272 KB
testcase_25 AC 509 ms
75,928 KB
testcase_26 AC 118 ms
75,944 KB
testcase_27 AC 374 ms
75,952 KB
testcase_28 AC 504 ms
75,924 KB
testcase_29 AC 502 ms
75,836 KB
testcase_30 AC 507 ms
76,284 KB
testcase_31 AC 500 ms
75,972 KB
testcase_32 AC 72 ms
71,272 KB
testcase_33 AC 89 ms
75,720 KB
testcase_34 AC 164 ms
75,836 KB
testcase_35 AC 967 ms
78,072 KB
testcase_36 AC 958 ms
78,112 KB
testcase_37 AC 1,008 ms
78,252 KB
testcase_38 AC 982 ms
78,004 KB
testcase_39 AC 983 ms
78,360 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))

def dfs(v,p):
    for u,d in g[v]:
        if u == p: continue
        dfs(u,v)
        for i in range(m,d-1,-1):
            for k in range(i-d+1):
                dp[v][i] = max(dp[v][i],dp[v][i-k-d] + dp[u][k])

dp = [[U[i]]*(m+1) for i in range(n)]
dfs(0,-1)
print(max(dp[0]))
0