結果
問題 |
No.1037 exhausted
|
ユーザー |
|
提出日時 | 2020-04-29 18:04:20 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 741 bytes |
コンパイル時間 | 73 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 85,760 KB |
最終ジャッジ日時 | 2024-11-29 05:14:04 |
合計ジャッジ時間 | 31,392 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 TLE * 10 |
ソースコード
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)