結果

問題 No.1037 exhausted
ユーザー tanon710tanon710
提出日時 2020-05-04 16:35:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 104,392 KB
最終ジャッジ日時 2023-09-06 20:33:18
合計ジャッジ時間 4,229 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,480 KB
testcase_01 AC 68 ms
70,980 KB
testcase_02 AC 60 ms
71,332 KB
testcase_03 AC 59 ms
71,496 KB
testcase_04 AC 61 ms
71,500 KB
testcase_05 AC 65 ms
71,108 KB
testcase_06 AC 65 ms
71,276 KB
testcase_07 AC 63 ms
71,228 KB
testcase_08 AC 61 ms
71,560 KB
testcase_09 AC 62 ms
71,496 KB
testcase_10 AC 63 ms
71,336 KB
testcase_11 AC 62 ms
71,300 KB
testcase_12 AC 208 ms
104,220 KB
testcase_13 AC 207 ms
104,104 KB
testcase_14 AC 207 ms
104,068 KB
testcase_15 AC 208 ms
104,188 KB
testcase_16 AC 209 ms
104,064 KB
testcase_17 AC 202 ms
103,648 KB
testcase_18 AC 211 ms
103,672 KB
testcase_19 AC 213 ms
104,392 KB
testcase_20 AC 119 ms
103,560 KB
testcase_21 AC 108 ms
102,964 KB
testcase_22 AC 114 ms
103,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,v,l=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
n+=1
arr.append([l,0,0])
dp=[[10**18]*(v+1) for _ in range(n+1)]
dp[0][v]=0
now=0
for i in range(n):
    dist=arr[i][0]-now
    gas=arr[i][1]
    cost=arr[i][2]
    flag=False
    for j in range(v-dist,-1,-1):
        dp[i+1][j]=dp[i][j+dist]
        if dp[i+1][j]!=10**18:
            flag=True
    if flag==False:
        print(-1)
        break
    else:
        for j in range(v,-1,-1):
            dp[i+1][min(v,j+gas)]=min(dp[i+1][min(v,j+gas)],dp[i+1][j]+cost)
    now=arr[i][0]
else:
    print(min(dp[-1]))
0