結果

問題 No.1037 exhausted
ユーザー tpynerivertpyneriver
提出日時 2020-04-24 22:18:46
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 458 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 356,160 KB
最終ジャッジ日時 2024-04-23 03:30:08
合計ジャッジ時間 5,791 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
59,844 KB
testcase_01 AC 38 ms
53,096 KB
testcase_02 AC 38 ms
53,080 KB
testcase_03 AC 38 ms
51,940 KB
testcase_04 AC 38 ms
52,644 KB
testcase_05 AC 37 ms
53,748 KB
testcase_06 AC 38 ms
53,484 KB
testcase_07 AC 38 ms
52,872 KB
testcase_08 AC 39 ms
52,948 KB
testcase_09 AC 37 ms
52,964 KB
testcase_10 AC 38 ms
53,852 KB
testcase_11 AC 38 ms
52,336 KB
testcase_12 AC 111 ms
77,008 KB
testcase_13 AC 113 ms
76,552 KB
testcase_14 AC 116 ms
77,060 KB
testcase_15 AC 113 ms
76,932 KB
testcase_16 AC 114 ms
76,752 KB
testcase_17 AC 113 ms
76,688 KB
testcase_18 AC 110 ms
76,816 KB
testcase_19 AC 110 ms
77,040 KB
testcase_20 AC 123 ms
78,452 KB
testcase_21 AC 167 ms
89,752 KB
testcase_22 TLE -
権限があれば一括ダウンロードができます

ソースコード

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