結果

問題 No.1037 exhausted
ユーザー tpynerivertpyneriver
提出日時 2020-04-24 22:29:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,400 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 263,268 KB
最終ジャッジ日時 2024-04-23 03:39:17
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,800 KB
testcase_01 AC 36 ms
52,940 KB
testcase_02 AC 35 ms
52,588 KB
testcase_03 AC 37 ms
52,820 KB
testcase_04 AC 36 ms
52,556 KB
testcase_05 AC 37 ms
52,344 KB
testcase_06 AC 38 ms
52,396 KB
testcase_07 AC 37 ms
53,016 KB
testcase_08 AC 36 ms
52,896 KB
testcase_09 AC 37 ms
53,536 KB
testcase_10 AC 37 ms
52,932 KB
testcase_11 AC 38 ms
52,212 KB
testcase_12 AC 112 ms
77,092 KB
testcase_13 AC 111 ms
77,156 KB
testcase_14 AC 110 ms
77,096 KB
testcase_15 AC 110 ms
77,260 KB
testcase_16 AC 112 ms
76,688 KB
testcase_17 AC 113 ms
76,720 KB
testcase_18 AC 113 ms
77,112 KB
testcase_19 AC 115 ms
76,772 KB
testcase_20 AC 106 ms
76,528 KB
testcase_21 AC 96 ms
77,052 KB
testcase_22 AC 1,400 ms
263,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
N, V, L = map(int, readline().split())

xvw = [tuple(map(int, readline().split())) for _ in range(N)]
INF = 1<<60
dp = [INF]*(V+1)
dp[V] = 0

pre = 0
for x, v, w in xvw:
    dist = x-pre
    dp2 = dp[dist:] + [INF]*dist
    dp2 = dp2[:V+1]
    for vi in range(V+1-dist):
        vidx = min(V, vi+v)
        dp2[vidx] = min(dp2[vidx], dp[vi+dist]+w)
    dp = dp2[:]
    pre = x
ans = min(dp[L-pre:]) if len(dp[L-pre:]) > 0 else INF
if ans == INF:
    ans = -1
print(ans)
0