結果
問題 |
No.1037 exhausted
|
ユーザー |
![]() |
提出日時 | 2020-06-05 18:35:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 614 bytes |
コンパイル時間 | 535 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 21,760 KB |
最終ジャッジ日時 | 2024-12-16 06:08:53 |
合計ジャッジ時間 | 31,554 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 TLE * 10 |
ソースコード
import sys input = sys.stdin.readline inf = 10 ** 18 N, V, L = map(int, input().split()) station = [tuple(map(int, input().split())) for _ in range(N)] station.append((L, 0, 0)) dp = [inf] * (V + 1) dp[V] = 0 pos = 0 for x, v, w in station: dist = x - pos newDP = [inf] * (V + 1) for i in range(dist, V + 1): # 補給しない gas = i - dist newDP[gas] = min(newDP[gas], dp[i]) # 補給する gas = min(V, i - dist + v) newDP[gas] = min(newDP[gas], dp[i] + w) dp = newDP pos = x ans = min(dp) if ans >= inf: print(-1) else: print(ans)