結果
問題 |
No.1037 exhausted
|
ユーザー |
|
提出日時 | 2020-04-29 18:04:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,098 ms / 2,000 ms |
コード長 | 741 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 82,264 KB |
実行使用メモリ | 144,932 KB |
最終ジャッジ日時 | 2024-11-29 05:16:16 |
合計ジャッジ時間 | 10,521 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
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)