結果

問題 No.1037 exhausted
ユーザー stngstng
提出日時 2022-08-31 21:28:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 77,212 KB
最終ジャッジ日時 2024-04-26 03:48:30
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,936 KB
testcase_01 AC 37 ms
52,760 KB
testcase_02 AC 37 ms
52,348 KB
testcase_03 AC 36 ms
52,720 KB
testcase_04 AC 36 ms
53,412 KB
testcase_05 AC 37 ms
52,280 KB
testcase_06 AC 37 ms
52,440 KB
testcase_07 AC 41 ms
52,320 KB
testcase_08 AC 37 ms
52,120 KB
testcase_09 AC 37 ms
53,452 KB
testcase_10 AC 37 ms
52,288 KB
testcase_11 AC 38 ms
53,368 KB
testcase_12 AC 136 ms
76,760 KB
testcase_13 AC 134 ms
77,116 KB
testcase_14 AC 135 ms
77,120 KB
testcase_15 AC 137 ms
77,096 KB
testcase_16 AC 135 ms
77,196 KB
testcase_17 AC 133 ms
76,904 KB
testcase_18 AC 130 ms
77,120 KB
testcase_19 AC 135 ms
76,780 KB
testcase_20 AC 131 ms
77,212 KB
testcase_21 AC 130 ms
76,988 KB
testcase_22 AC 121 ms
76,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

inf = 10**15

dp = [inf]*(v+1)
dp[v] = 0
pos = 0

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

if ans >= inf:
    print(-1)
else:
    print(ans)
0