結果

問題 No.1037 exhausted
ユーザー stngstng
提出日時 2022-08-31 21:09:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,384 KB
最終ジャッジ日時 2024-04-26 03:33:03
合計ジャッジ時間 3,408 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,488 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 36 ms
52,480 KB
testcase_03 AC 40 ms
52,224 KB
testcase_04 AC 38 ms
52,352 KB
testcase_05 AC 39 ms
52,608 KB
testcase_06 AC 39 ms
51,968 KB
testcase_07 WA -
testcase_08 AC 37 ms
52,736 KB
testcase_09 WA -
testcase_10 AC 38 ms
52,096 KB
testcase_11 WA -
testcase_12 AC 134 ms
76,768 KB
testcase_13 AC 127 ms
76,928 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 129 ms
77,124 KB
testcase_17 AC 133 ms
76,936 KB
testcase_18 AC 134 ms
77,000 KB
testcase_19 WA -
testcase_20 AC 126 ms
76,800 KB
testcase_21 AC 130 ms
76,928 KB
testcase_22 AC 120 ms
76,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,v,l = map(int,input().split())
xvw = [[int(i) for i in input().split()] for j in range(n)]

dp = [10**15]*(v+1)
dp[v] = 0
pos = 0
#print(dp)
for i in range(n):
    x,vi,wi = xvw[i]
    dis = x-pos
    for j in range(v+1):
        if dis > j:
            dp[j] = 10**15
        else:
            dp[j-dis] = dp[j]
            if dis != 0:
                dp[j] = 10**15
    #print(dis)
    #print(dp,111)
    for j in range(v+1):
        dp[min(v,j+vi)] = min(dp[j]+wi,dp[min(v,j+vi)])
    pos = x
    #print(dp,i)
#print(dp)
#exit()
if pos != l:
    dis = l-pos
    ans = 10**15
    for j in range(v+1):
        if dis <= j:
            ans = min(ans,dp[j])
else:
    ans = min(dp)

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