結果

問題 No.1037 exhausted
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-05 18:39:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 82,548 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-05-09 15:58:17
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
51,456 KB
testcase_01 AC 33 ms
51,712 KB
testcase_02 AC 34 ms
51,200 KB
testcase_03 AC 35 ms
51,840 KB
testcase_04 AC 36 ms
52,096 KB
testcase_05 AC 32 ms
52,352 KB
testcase_06 AC 32 ms
51,840 KB
testcase_07 AC 32 ms
52,224 KB
testcase_08 AC 32 ms
51,968 KB
testcase_09 AC 32 ms
52,352 KB
testcase_10 AC 33 ms
51,968 KB
testcase_11 AC 33 ms
52,096 KB
testcase_12 AC 149 ms
76,800 KB
testcase_13 AC 155 ms
77,056 KB
testcase_14 AC 143 ms
76,516 KB
testcase_15 AC 143 ms
76,800 KB
testcase_16 AC 147 ms
76,388 KB
testcase_17 AC 162 ms
76,288 KB
testcase_18 AC 144 ms
77,048 KB
testcase_19 AC 144 ms
76,676 KB
testcase_20 AC 96 ms
76,672 KB
testcase_21 AC 81 ms
76,032 KB
testcase_22 AC 69 ms
76,032 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