Question
Two Lane Delivery Switch

An Amazon delivery robot moves through n checkpoints.

Each checkpoint has two lanes: lane 1 and lane 2.

If the robot visits checkpoint i in lane 1, it gains reward top_i.

If the robot visits checkpoint i in lane 2, it gains reward bottom_i.

The robot must visit exactly one lane at every checkpoint from 1 to n.

Between two consecutive checkpoints, the robot may stay in the same lane for free, or switch to the other lane by paying a switching cost of c.

Your task is to find the maximum total reward the robot can collect after subtracting all switching costs.

Input

The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of checkpoints and the cost of switching lanes.

The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the rewards in lane KaTeX can only parse string typed expression.

The third line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the rewards in lane KaTeX can only parse string typed expression.

Output

Print a single integer — the maximum total reward after subtracting switching costs.

Example
Example 1:
Input
5 3

5 1 10 1 5
1 8 1 9 1
Output
25
Explanation
One optimal path is lane KaTeX can only parse string typed expression, lane KaTeX can only parse string typed expression, lane KaTeX can only parse string typed expression, lane KaTeX can only parse string typed expression, lane KaTeX can only parse string typed expression.
The collected reward is KaTeX can only parse string typed expression.
The robot switches lanes KaTeX can only parse string typed expression times, so the switching cost is KaTeX can only parse string typed expression.
The final reward is KaTeX can only parse string typed expression.

Example 2:
Input
3 100

5 5 5
1 100 1
Output
102
Explanation
Switching is very expensive. The best choice is to stay in lane KaTeX can only parse string typed expression for all checkpoints and collect KaTeX can only parse string typed expression.

Example 3:
Input
1 50

7
20
Output
20
Explanation
There is only one checkpoint, so no switching is needed. The robot chooses lane KaTeX can only parse string typed expression and collects KaTeX can only parse string typed expression.

Online