結果

問題 No.1037 exhausted
ユーザー 👑 rin204rin204
提出日時 2022-07-10 16:16:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 1,122 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 78,192 KB
最終ジャッジ日時 2023-09-01 23:04:28
合計ジャッジ時間 4,604 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,432 KB
testcase_01 AC 72 ms
71,492 KB
testcase_02 AC 72 ms
71,504 KB
testcase_03 AC 72 ms
71,440 KB
testcase_04 AC 71 ms
71,492 KB
testcase_05 AC 71 ms
71,296 KB
testcase_06 AC 70 ms
71,488 KB
testcase_07 AC 71 ms
71,324 KB
testcase_08 AC 72 ms
71,276 KB
testcase_09 AC 71 ms
71,596 KB
testcase_10 AC 71 ms
71,292 KB
testcase_11 AC 72 ms
71,416 KB
testcase_12 AC 173 ms
78,120 KB
testcase_13 AC 185 ms
78,192 KB
testcase_14 AC 164 ms
77,840 KB
testcase_15 AC 166 ms
78,004 KB
testcase_16 AC 167 ms
78,056 KB
testcase_17 AC 174 ms
78,160 KB
testcase_18 AC 161 ms
78,064 KB
testcase_19 AC 164 ms
78,100 KB
testcase_20 AC 154 ms
77,664 KB
testcase_21 AC 147 ms
77,956 KB
testcase_22 AC 140 ms
77,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, V_, l = map(int, input().split())
X = [-1] * n
V = [-1] * n
W = [-1] * n
for i in range(n):
    X[i], V[i], W[i] = map(int, input().split())
bef = 0
inf = 1 << 60
dp = [inf] * (V_ + 1)
dp[V_] = 0
for x, v, w in zip(X, V, W):
    d = x - bef
    bef = x
    ndp = [inf] * (V_ + 1)
    for i in range(d, V_ + 1):
        ndp[i - d] = dp[i]
    for i in range(V_, -1, -1):
        j = min(V_, i + v)
        ndp[j] = min(ndp[j], ndp[i] + w)
    dp = ndp
d = l - bef
try:
    ans = min(dp[d:])
    if ans == inf:
        ans = -1
    print(ans)
except:
    print(-1)


0