#P1249E. By Elevator or Stairs?
By Elevator or Stairs?
No submission language available for this problem.
Description
You are planning to buy an apartment in a -floor building. The floors are numbered from to from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor.
Let:
- for all from to be the time required to go from the -th floor to the -th one (and from the -th to the -th as well) using the stairs;
- for all from to be the time required to go from the -th floor to the -th one (and from the -th to the -th as well) using the elevator, also there is a value — time overhead for elevator usage (you need to wait for it, the elevator doors are too slow!).
In one move, you can go from the floor you are staying at to any floor () in two different ways:
- If you are using the stairs, just sum up the corresponding values of . Formally, it will take time units.
- If you are using the elevator, just sum up and the corresponding values of . Formally, it will take time units.
You can perform as many moves as you want (possibly zero).
So your task is for each to determine the minimum total time it takes to reach the -th floor from the -st (bottom) floor.
The first line of the input contains two integers and () — the number of floors in the building and the time overhead for the elevator rides.
The second line of the input contains integers (), where is the time required to go from the -th floor to the -th one (and from the -th to the -th as well) using the stairs.
The third line of the input contains integers (), where is the time required to go from the -th floor to the -th one (and from the -th to the -th as well) using the elevator.
Print integers , where is the minimum total time to reach the -th floor from the first floor if you can perform as many moves as you want.
Input
The first line of the input contains two integers and () — the number of floors in the building and the time overhead for the elevator rides.
The second line of the input contains integers (), where is the time required to go from the -th floor to the -th one (and from the -th to the -th as well) using the stairs.
The third line of the input contains integers (), where is the time required to go from the -th floor to the -th one (and from the -th to the -th as well) using the elevator.
Output
Print integers , where is the minimum total time to reach the -th floor from the first floor if you can perform as many moves as you want.