結果
問題 |
No.1037 exhausted
|
ユーザー |
![]() |
提出日時 | 2020-08-03 00:23:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 447 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 142,080 KB |
最終ジャッジ日時 | 2024-07-19 21:15:38 |
合計ジャッジ時間 | 4,683 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 9 |
ソースコード
import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) #処理内容 def main(): N, V, L = getlist() DP = [[INF] * (V + 1) for i in range(N + 2)] DP[0][V] = 0 xnow = 0 for i in range(1, N + 1): x, v, w = getlist() for j in range(V + 1): if j >= v: DP[i][j] = min(DP[i][j], DP[i][j - v] + w) if j + (x - xnow) <= V: DP[i][j] = min(DP[i][j], DP[i - 1][j + (x - xnow)]) xnow = x for j in range(V + 1): if j + (L - xnow) <= V: DP[N + 1][j] = min(DP[N + 1][j], DP[N][j + (L - xnow)]) # print(DP) ans = min(DP[-1]) if ans == INF: print(-1) else: print(ans) if __name__ == '__main__': main()