結果

問題 No.1037 exhausted
ユーザー tpynerivertpyneriver
提出日時 2020-04-24 22:22:07
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 478 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 82,148 KB
実行使用メモリ 264,104 KB
最終ジャッジ日時 2024-04-23 03:32:55
合計ジャッジ時間 4,134 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,904 KB
testcase_01 AC 41 ms
52,720 KB
testcase_02 AC 40 ms
52,332 KB
testcase_03 AC 38 ms
52,004 KB
testcase_04 AC 40 ms
52,692 KB
testcase_05 RE -
testcase_06 AC 37 ms
52,884 KB
testcase_07 AC 39 ms
52,828 KB
testcase_08 AC 38 ms
52,088 KB
testcase_09 AC 38 ms
54,024 KB
testcase_10 AC 39 ms
52,188 KB
testcase_11 AC 37 ms
53,780 KB
testcase_12 AC 120 ms
76,876 KB
testcase_13 AC 120 ms
77,092 KB
testcase_14 AC 123 ms
77,148 KB
testcase_15 AC 122 ms
76,836 KB
testcase_16 AC 124 ms
76,632 KB
testcase_17 AC 125 ms
76,776 KB
testcase_18 AC 122 ms
77,236 KB
testcase_19 AC 124 ms
76,792 KB
testcase_20 AC 110 ms
76,816 KB
testcase_21 AC 100 ms
76,960 KB
testcase_22 RE -
権限があれば一括ダウンロードができます

ソースコード

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 ans == INF:
    ans = -1
print(ans)
0