結果

問題 No.417 チューリップバブル
ユーザー neko0774neko0774
提出日時 2023-01-31 14:12:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 987 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 78,068 KB
最終ジャッジ日時 2023-09-13 07:27:00
合計ジャッジ時間 14,333 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,180 KB
testcase_01 AC 76 ms
75,396 KB
testcase_02 AC 74 ms
75,160 KB
testcase_03 AC 74 ms
75,544 KB
testcase_04 AC 68 ms
71,380 KB
testcase_05 AC 71 ms
71,188 KB
testcase_06 AC 78 ms
75,848 KB
testcase_07 AC 76 ms
75,808 KB
testcase_08 AC 86 ms
75,892 KB
testcase_09 AC 99 ms
75,912 KB
testcase_10 AC 107 ms
76,008 KB
testcase_11 AC 201 ms
75,816 KB
testcase_12 AC 200 ms
75,848 KB
testcase_13 AC 126 ms
75,860 KB
testcase_14 AC 276 ms
76,108 KB
testcase_15 AC 92 ms
75,652 KB
testcase_16 AC 91 ms
75,920 KB
testcase_17 AC 187 ms
75,744 KB
testcase_18 AC 187 ms
75,684 KB
testcase_19 AC 189 ms
75,904 KB
testcase_20 AC 501 ms
77,364 KB
testcase_21 AC 496 ms
77,024 KB
testcase_22 AC 500 ms
77,076 KB
testcase_23 AC 496 ms
77,196 KB
testcase_24 AC 78 ms
75,548 KB
testcase_25 AC 499 ms
77,168 KB
testcase_26 AC 117 ms
75,800 KB
testcase_27 AC 367 ms
75,744 KB
testcase_28 AC 496 ms
77,164 KB
testcase_29 AC 492 ms
77,136 KB
testcase_30 AC 496 ms
77,032 KB
testcase_31 AC 492 ms
77,208 KB
testcase_32 AC 71 ms
71,172 KB
testcase_33 AC 89 ms
75,740 KB
testcase_34 AC 162 ms
75,924 KB
testcase_35 AC 946 ms
78,068 KB
testcase_36 AC 934 ms
78,044 KB
testcase_37 AC 987 ms
78,060 KB
testcase_38 AC 956 ms
77,872 KB
testcase_39 AC 957 ms
77,972 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))
dp = [[U[i]]*(M+1) for i in range(N)]
def dfs(x, par=-1):
    for nx, t in G[x]:
        if nx==par:
            continue
        dfs(nx, x)
        for m in range(M+1)[::-1]:
            for mm in range(M-m+1-t):
                T = m+mm+t
                dp[x][T] = max(dp[x][T], dp[x][m]+dp[nx][mm])
dfs(0)
print(max(dp[0]))
0