結果
問題 |
No.1037 exhausted
|
ユーザー |
|
提出日時 | 2020-04-24 23:27:26 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 938 bytes |
コンパイル時間 | 127 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 47,872 KB |
最終ジャッジ日時 | 2024-10-15 03:51:43 |
合計ジャッジ時間 | 4,142 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 TLE * 1 -- * 10 |
ソースコード
INF = 10 ** 16 MOD = 10 **9 + 7 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque from math import factorial def main(): n,V,L = map(int,input().split()) Gas = [(0,0,INF)] + [tuple(map(int,input().split())) for _ in range(n)] + [(L,0,INF)] dp = [[0] * (V + 1)] + [[INF] * (V + 1) for _ in range(n + 1)] for i in range(n + 1): before_x,before_v,before_w = Gas[i] x,v,w = Gas[i + 1] for j in range(V + 1): if min(j + before_v,V) - x + before_x >= 0: dp[i + 1][min(j + before_v,V) - x + before_x] = min(dp[i + 1][min(j + before_v,V) - x + before_x],dp[i][j] + before_w) if j - x + before_x >= 0: dp[i + 1][j - x + before_x] = min(dp[i + 1][j - x + before_x],dp[i][j]) ans = min(dp[-1]) print(ans if ans != INF else -1) if __name__=='__main__': main()