結果
問題 | No.1037 exhausted |
ユーザー | 双六 |
提出日時 | 2020-08-03 00:27:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 849 bytes |
コンパイル時間 | 1,346 ms |
コンパイル使用メモリ | 87,020 KB |
実行使用メモリ | 143,996 KB |
最終ジャッジ日時 | 2023-09-27 07:02:04 |
合計ジャッジ時間 | 6,817 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
71,784 KB |
testcase_01 | AC | 78 ms
71,840 KB |
testcase_02 | AC | 80 ms
71,652 KB |
testcase_03 | AC | 80 ms
71,724 KB |
testcase_04 | AC | 80 ms
71,448 KB |
testcase_05 | AC | 84 ms
71,588 KB |
testcase_06 | AC | 81 ms
71,540 KB |
testcase_07 | WA | - |
testcase_08 | AC | 79 ms
71,568 KB |
testcase_09 | WA | - |
testcase_10 | AC | 80 ms
71,716 KB |
testcase_11 | WA | - |
testcase_12 | AC | 357 ms
130,592 KB |
testcase_13 | AC | 346 ms
128,308 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 365 ms
123,880 KB |
testcase_17 | AC | 365 ms
129,560 KB |
testcase_18 | AC | 369 ms
135,616 KB |
testcase_19 | WA | - |
testcase_20 | AC | 324 ms
111,436 KB |
testcase_21 | AC | 186 ms
100,104 KB |
testcase_22 | AC | 205 ms
109,512 KB |
ソースコード
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 + (x - xnow) <= V: DP[i][j] = min(DP[i][j], DP[i - 1][j + (x - xnow)]) DP[i][min(V, j + v)] = min(DP[i][min(V, j + v)], DP[i][j] + w) # if j >= v: # DP[i][j] = min(DP[i][j], DP[i][j - v] + w) 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()