結果
| 問題 |
No.1037 exhausted
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-10 16:16:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 2,000 ms |
| コード長 | 568 bytes |
| コンパイル時間 | 375 ms |
| コンパイル使用メモリ | 82,408 KB |
| 実行使用メモリ | 76,984 KB |
| 最終ジャッジ日時 | 2025-01-03 11:07:55 |
| 合計ジャッジ時間 | 3,576 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
n, V_, l = map(int, input().split())
X = [-1] * n
V = [-1] * n
W = [-1] * n
for i in range(n):
X[i], V[i], W[i] = map(int, input().split())
bef = 0
inf = 1 << 60
dp = [inf] * (V_ + 1)
dp[V_] = 0
for x, v, w in zip(X, V, W):
d = x - bef
bef = x
ndp = [inf] * (V_ + 1)
for i in range(d, V_ + 1):
ndp[i - d] = dp[i]
for i in range(V_, -1, -1):
j = min(V_, i + v)
ndp[j] = min(ndp[j], ndp[i] + w)
dp = ndp
d = l - bef
try:
ans = min(dp[d:])
if ans == inf:
ans = -1
print(ans)
except:
print(-1)