結果

問題 No.1037 exhausted
ユーザー roarisroaris
提出日時 2020-04-27 15:52:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 109,852 KB
最終ジャッジ日時 2023-08-14 02:03:29
合計ジャッジ時間 5,220 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,356 KB
testcase_01 AC 69 ms
71,244 KB
testcase_02 AC 69 ms
71,336 KB
testcase_03 AC 69 ms
71,424 KB
testcase_04 AC 69 ms
71,256 KB
testcase_05 AC 68 ms
71,100 KB
testcase_06 AC 70 ms
71,260 KB
testcase_07 AC 70 ms
71,284 KB
testcase_08 AC 69 ms
71,364 KB
testcase_09 AC 69 ms
71,260 KB
testcase_10 AC 68 ms
71,484 KB
testcase_11 AC 70 ms
71,352 KB
testcase_12 AC 244 ms
109,664 KB
testcase_13 AC 265 ms
109,668 KB
testcase_14 AC 250 ms
109,576 KB
testcase_15 AC 245 ms
109,676 KB
testcase_16 AC 252 ms
109,312 KB
testcase_17 AC 254 ms
109,476 KB
testcase_18 AC 247 ms
109,300 KB
testcase_19 AC 250 ms
109,852 KB
testcase_20 AC 174 ms
108,544 KB
testcase_21 AC 156 ms
109,016 KB
testcase_22 AC 125 ms
108,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, V, L = map(int, input().split())
dp = [[10**18]*(V+1) for _ in range(N+1)]
dp[0][V] = 0
prev_x = 0

for i in range(N):
    x, v, w = map(int, input().split())
    use = x-prev_x
    
    for j in range(use, V+1):
        dp[i+1][j-use] = min(dp[i+1][j-use], dp[i][j])
        dp[i+1][min(V, j-use+v)] = min(dp[i+1][min(V, j-use+v)], dp[i][j]+w)
    
    prev_x = x
    
ans = 10**18

for i in range(L-prev_x, V+1):
    ans = min(ans, dp[N][i])

if ans==10**18:
    print(-1)
else:
    print(ans)
0