結果

問題 No.1037 exhausted
ユーザー ayaoniayaoni
提出日時 2020-12-14 04:38:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,912 KB
実行使用メモリ 107,780 KB
最終ジャッジ日時 2023-10-20 04:41:16
合計ジャッジ時間 3,247 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,492 KB
testcase_01 AC 38 ms
53,492 KB
testcase_02 AC 38 ms
53,492 KB
testcase_03 AC 38 ms
53,492 KB
testcase_04 WA -
testcase_05 AC 38 ms
53,492 KB
testcase_06 AC 38 ms
53,492 KB
testcase_07 WA -
testcase_08 AC 37 ms
53,492 KB
testcase_09 AC 37 ms
53,492 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 167 ms
107,612 KB
testcase_13 AC 172 ms
107,588 KB
testcase_14 AC 167 ms
107,480 KB
testcase_15 AC 171 ms
107,588 KB
testcase_16 WA -
testcase_17 AC 169 ms
107,676 KB
testcase_18 AC 165 ms
107,576 KB
testcase_19 AC 165 ms
107,568 KB
testcase_20 AC 190 ms
107,580 KB
testcase_21 AC 149 ms
107,660 KB
testcase_22 AC 120 ms
107,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,V,L = MI()
XVW = [(0,0,0)]+[tuple(MI()) for _ in range(N)]
XVW.sort()

inf = 10**18
dp = [[inf]*(V+1) for _ in range(N+1)]
# dp[i][j] = i番目の地点に到達した際に、j以上の燃料を残すために必要な費用の最小値

for j in range(V+1):
    dp[0][j] = 0

for i in range(1,N+1):
    x,v,w = XVW[i]
    d = x-XVW[i-1][0]
    for j in range(V+1):
        if j+d <= V:
            dp[i][j] = min(dp[i][j],dp[i-1][j+d])
        if j >= v and j+d-v <= V:
            dp[i][j] = min(dp[i][j],dp[i-1][max(j+d-v,0)]+w)

y = L-XVW[-1][0]

if y > V:
    print(-1)
else:
    ans = dp[-1][y]
    if ans >= inf:
        print(-1)
    else:
        print(ans)
0