結果

問題 No.1037 exhausted
ユーザー KodaiKodai
提出日時 2020-04-29 18:04:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 741 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 44,680 KB
最終ジャッジ日時 2023-08-19 12:22:18
合計ジャッジ時間 4,458 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,824 KB
testcase_01 AC 17 ms
7,952 KB
testcase_02 AC 16 ms
7,792 KB
testcase_03 AC 16 ms
7,804 KB
testcase_04 AC 16 ms
7,768 KB
testcase_05 AC 16 ms
7,772 KB
testcase_06 AC 16 ms
7,824 KB
testcase_07 AC 16 ms
7,828 KB
testcase_08 AC 16 ms
7,796 KB
testcase_09 AC 16 ms
7,840 KB
testcase_10 AC 16 ms
7,752 KB
testcase_11 AC 16 ms
7,776 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp_list = [[float("inf")] * (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]])
        gas = min([V, v - dis_list[n] + shop_list[n][1]])
        dp_list[n + 1][gas] = min([dp_list[n + 1][gas], dp_list[n][v] + shop_list[n][2]])

ans = min(dp_list[-1])
if min(dp_list[-1]) == float("inf"):
    print(-1)
else:
    print(ans)
0