CF1809F Traveling in Berland

Description

There are $ n $ cities in Berland, arranged in a circle and numbered from $ 1 $ to $ n $ in clockwise order. You want to travel all over Berland, starting in some city, visiting all the other cities and returning to the starting city. Unfortunately, you can only drive along the Berland Ring Highway, which connects all $ n $ cities. The road was designed by a very titled and respectable minister, so it is one-directional — it can only be traversed clockwise, only from the city $ i $ to the city $ (i \bmod n) + 1 $ (i.e. from $ 1 $ to $ 2 $ , from $ 2 $ in $ 3 $ , ..., from $ n $ to $ 1 $ ). The fuel tank of your car holds up to $ k $ liters of fuel. To drive from the $ i $ -th city to the next one, $ a_i $ liters of fuel are needed (and are consumed in the process). Every city has a fuel station; a liter of fuel in the $ i $ -th city costs $ b_i $ burles. Refueling between cities is not allowed; if fuel has run out between cities, then your journey is considered incomplete. For each city, calculate the minimum cost of the journey if you start and finish it in that city.

Input Format

N/A

Output Format

N/A