結果

問題 No.1037 exhausted
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-05 18:39:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 78,480 KB
最終ジャッジ日時 2023-08-22 10:20:24
合計ジャッジ時間 4,357 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,332 KB
testcase_01 AC 71 ms
71,328 KB
testcase_02 AC 72 ms
71,200 KB
testcase_03 AC 72 ms
71,584 KB
testcase_04 AC 73 ms
71,400 KB
testcase_05 AC 74 ms
71,412 KB
testcase_06 AC 75 ms
71,376 KB
testcase_07 AC 72 ms
71,384 KB
testcase_08 AC 73 ms
71,216 KB
testcase_09 AC 73 ms
71,616 KB
testcase_10 AC 73 ms
71,300 KB
testcase_11 AC 74 ms
71,524 KB
testcase_12 AC 190 ms
78,260 KB
testcase_13 AC 199 ms
78,480 KB
testcase_14 AC 189 ms
78,244 KB
testcase_15 AC 187 ms
78,256 KB
testcase_16 AC 189 ms
78,244 KB
testcase_17 AC 191 ms
78,460 KB
testcase_18 AC 184 ms
78,052 KB
testcase_19 AC 190 ms
78,124 KB
testcase_20 AC 129 ms
77,908 KB
testcase_21 AC 116 ms
77,976 KB
testcase_22 AC 101 ms
77,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0