結果

問題 No.1037 exhausted
ユーザー stngstng
提出日時 2022-08-31 21:00:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-04-26 03:23:23
合計ジャッジ時間 3,020 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,648 KB
testcase_01 AC 36 ms
52,524 KB
testcase_02 WA -
testcase_03 AC 38 ms
52,716 KB
testcase_04 WA -
testcase_05 AC 36 ms
52,124 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 36 ms
52,748 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 129 ms
76,840 KB
testcase_21 AC 124 ms
76,704 KB
testcase_22 AC 122 ms
76,644 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]
            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