結果
| 問題 |
No.1037 exhausted
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-02 13:18:11 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 604 ms / 2,000 ms |
| コード長 | 696 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 44,492 KB |
| 最終ジャッジ日時 | 2024-07-20 06:56:41 |
| 合計ジャッジ時間 | 14,479 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import numpy as np
N, V, L = map(int, input().split())
INF = 10 ** 18
dp = np.full(V + 1, INF)
dp[V] = 0
cur = 0
for _ in range(N):
new_dp = np.full(V + 1, INF)
x, v, w = map(int, input().split())
if v == 0:
continue
dist = x - cur
if dist > V:
print(-1)
exit()
new_dp[:V + 1 - dist] = dp[dist:]
dp = new_dp.copy()
if v <= V:
new_dp[v:] = np.minimum(new_dp[v:], dp[:-v] + w)
new_dp[V] = min(new_dp[V], np.min(dp[-v:]) + w)
else:
new_dp[V] = min(new_dp[V], np.min(dp) + w)
dp = new_dp.copy()
cur = x
if L - cur > V:
print(-1)
exit()
ans = np.min(dp[L - cur:])
print(ans if ans != INF else -1)