結果

問題 No.1037 exhausted
ユーザー KodaiKodai
提出日時 2020-04-29 17:23:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,548 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 147,004 KB
最終ジャッジ日時 2023-08-19 11:12:04
合計ジャッジ時間 16,344 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,372 KB
testcase_01 AC 70 ms
71,380 KB
testcase_02 AC 70 ms
71,208 KB
testcase_03 AC 71 ms
71,376 KB
testcase_04 AC 68 ms
71,480 KB
testcase_05 AC 71 ms
71,256 KB
testcase_06 AC 70 ms
71,388 KB
testcase_07 AC 68 ms
71,328 KB
testcase_08 AC 70 ms
71,412 KB
testcase_09 AC 70 ms
71,376 KB
testcase_10 AC 70 ms
71,376 KB
testcase_11 AC 71 ms
71,496 KB
testcase_12 AC 1,548 ms
146,760 KB
testcase_13 AC 1,511 ms
147,004 KB
testcase_14 AC 1,413 ms
144,580 KB
testcase_15 AC 1,375 ms
143,408 KB
testcase_16 AC 1,436 ms
145,576 KB
testcase_17 AC 1,440 ms
146,868 KB
testcase_18 AC 1,460 ms
143,972 KB
testcase_19 AC 1,471 ms
145,492 KB
testcase_20 AC 936 ms
111,264 KB
testcase_21 AC 662 ms
109,708 KB
testcase_22 AC 294 ms
109,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, V, L = list(map(int, input().split()))
shop_list = [list(map(int, input().split())) for i in range(N)] + [[0, 0, 0]]
dis_list = [shop_list[0][0]] + [(shop_list[i + 1][0] - shop_list[i][0])
                                for i in range(len(shop_list) - 2)] + [L - shop_list[-2][0]]

dp_list = [[float("inf") for i in range(V + 1)] for j in range(N + 2)]
dp_list[0][V] = 0

for n in range(N + 1):
    for v in range(dis_list[n], V + 1):
        dp_list[n + 1][v - dis_list[n]] = min([dp_list[n + 1][v - dis_list[n]], dp_list[n][v]])
        dp_list[n + 1][min([V, v - dis_list[n] + shop_list[n][1]])
                       ] = min([dp_list[n + 1][min([V, v - dis_list[n] + shop_list[n][1]])], dp_list[n][v] + shop_list[n][2]])

print(min(dp_list[N + 1]) if min(dp_list[N + 1]) != float("inf") else -1)
0