結果
問題 | No.417 チューリップバブル |
ユーザー | Yukino DX. |
提出日時 | 2023-11-11 12:16:22 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 696 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 83,508 KB |
最終ジャッジ日時 | 2023-11-11 12:16:36 |
合計ジャッジ時間 | 14,433 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
61,856 KB |
testcase_01 | AC | 50 ms
61,860 KB |
testcase_02 | AC | 46 ms
61,856 KB |
testcase_03 | AC | 46 ms
61,856 KB |
testcase_04 | AC | 37 ms
53,460 KB |
testcase_05 | AC | 38 ms
53,460 KB |
testcase_06 | AC | 50 ms
63,944 KB |
testcase_07 | AC | 49 ms
61,856 KB |
testcase_08 | AC | 132 ms
75,336 KB |
testcase_09 | AC | 238 ms
75,316 KB |
testcase_10 | AC | 305 ms
75,428 KB |
testcase_11 | AC | 1,232 ms
75,680 KB |
testcase_12 | AC | 1,216 ms
75,680 KB |
testcase_13 | AC | 498 ms
75,552 KB |
testcase_14 | AC | 1,923 ms
75,936 KB |
testcase_15 | AC | 182 ms
75,464 KB |
testcase_16 | AC | 174 ms
75,464 KB |
testcase_17 | AC | 1,062 ms
75,936 KB |
testcase_18 | AC | 1,049 ms
75,936 KB |
testcase_19 | AC | 1,039 ms
75,936 KB |
testcase_20 | TLE | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
ソースコード
from itertools import count 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)) dp = [[0] * (m + 1) for _ in range(n)] def dfs(crr, prv): for nxt, _ in g[crr]: if nxt != prv: dfs(nxt, crr) for nxt, t in g[crr]: for i in range(m, -1, -1): for j in count(0): if i < 2 * t + j: break dp[crr][i] = max(dp[crr][i], dp[crr][i - (2 * t + j)] + dp[nxt][j]) for i in range(m + 1): dp[crr][i] += u[crr] dfs(0, n) print(dp[0][m])