結果

問題 No.1037 exhausted
ユーザー roarisroaris
提出日時 2020-04-24 22:46:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 108,268 KB
最終ジャッジ日時 2024-04-23 03:44:39
合計ジャッジ時間 3,406 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,400 KB
testcase_01 AC 38 ms
52,936 KB
testcase_02 AC 37 ms
52,332 KB
testcase_03 AC 37 ms
52,252 KB
testcase_04 AC 38 ms
53,916 KB
testcase_05 AC 37 ms
52,820 KB
testcase_06 AC 37 ms
53,016 KB
testcase_07 AC 37 ms
52,252 KB
testcase_08 AC 38 ms
52,064 KB
testcase_09 AC 37 ms
52,280 KB
testcase_10 AC 37 ms
52,424 KB
testcase_11 AC 37 ms
52,676 KB
testcase_12 AC 200 ms
107,680 KB
testcase_13 AC 201 ms
108,268 KB
testcase_14 AC 203 ms
107,956 KB
testcase_15 AC 200 ms
107,832 KB
testcase_16 AC 205 ms
107,780 KB
testcase_17 AC 204 ms
107,984 KB
testcase_18 AC 201 ms
108,028 KB
testcase_19 AC 205 ms
107,852 KB
testcase_20 AC 149 ms
107,768 KB
testcase_21 AC 119 ms
92,216 KB
testcase_22 AC 105 ms
107,892 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(V+1):
        if j<use:
            continue
        
        dp[i+1][j-use] = min(dp[i+1][j-use], dp[i][j])
        k = min(V, j-use+v)
        dp[i+1][k] = min(dp[i+1][k], dp[i][j]+w)

    prev_x = x

ans = 10**18
use = L-prev_x

for i in range(V+1):
    if i<use:
        continue
    
    ans = min(ans, dp[N][i])

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