結果
| 問題 |
No.1037 exhausted
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-04-13 12:17:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 180 ms / 2,000 ms |
| コード長 | 643 bytes |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 82,392 KB |
| 実行使用メモリ | 76,804 KB |
| 最終ジャッジ日時 | 2024-10-09 10:43:57 |
| 合計ジャッジ時間 | 3,654 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
N, VV, L = map(int, input().split())
X, V, W = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1)
for i in range(N):
X[i + 1], V[i + 1], W[i + 1] = map(int, input().split())
inf = 10 ** 18
pre = [inf] * (VV + 1)
pre[VV] = 0
for i in range(N):
dp = [inf] * (VV + 1)
x = X[i + 1] - X[i]
for j in range(VV + 1):
if j - x >= 0:
dp[j - x] = min(dp[j - x], pre[j])
dp[min(VV, j - x + V[i + 1])] = min(dp[min(VV, j - x + V[i + 1])], pre[j] + W[i + 1])
dp, pre = pre, dp
ans = inf
for i in range(VV + 1):
if i - (L - X[-1]) >= 0:
ans = min(ans, pre[i])
print(ans) if ans < inf else print(-1)
rlangevin