結果

問題 No.1037 exhausted
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-04-24 23:56:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 77,112 KB
最終ジャッジ日時 2024-04-23 04:24:25
合計ジャッジ時間 2,733 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,240 KB
testcase_01 AC 38 ms
53,388 KB
testcase_02 AC 38 ms
53,012 KB
testcase_03 AC 36 ms
54,096 KB
testcase_04 AC 37 ms
52,688 KB
testcase_05 AC 38 ms
52,576 KB
testcase_06 AC 38 ms
53,812 KB
testcase_07 AC 38 ms
52,432 KB
testcase_08 AC 38 ms
52,636 KB
testcase_09 AC 38 ms
52,192 KB
testcase_10 AC 38 ms
52,660 KB
testcase_11 AC 38 ms
52,340 KB
testcase_12 AC 123 ms
77,112 KB
testcase_13 AC 120 ms
76,272 KB
testcase_14 AC 118 ms
76,680 KB
testcase_15 AC 119 ms
76,376 KB
testcase_16 AC 121 ms
76,652 KB
testcase_17 AC 121 ms
76,312 KB
testcase_18 AC 118 ms
76,728 KB
testcase_19 AC 120 ms
76,824 KB
testcase_20 AC 128 ms
76,348 KB
testcase_21 AC 129 ms
76,268 KB
testcase_22 AC 106 ms
76,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, V, L = map(int, input().split())
inf = 10**18
dp = [inf]*(V+1)
dp[V] = 0
bx = 0
for _ in range(N):
    ndp = [inf] * (V+1)
    x, v, w = map(int, input().split())
    for vl in range(V+1):
        if vl+(x-bx) > V:
            continue
        ndp[vl] = dp[vl+(x-bx)]
    for vl in range(V, -1, -1):
        vi = min(vl+v, V)
        ndp[vi] = min(ndp[vi], ndp[vl]+w)
    dp = ndp
    bx = x
R = min([inf]+dp[L-bx:])
if R >= inf:
    print(-1)
else:
    print(R)
0