#P9209. 不灭「不死鸟之尾」
不灭「不死鸟之尾」
Description
There is a parking lot with parking spaces arranged in a single line, with walls on both the far left and far right.
There are cars that will park in this lot in order. When parking the -th car, the more empty spaces there are on the left and right of the chosen spot, the less time it takes to park. Specifically, if the number of consecutive empty spaces on its left is and on its right is , then the time needed to park this car is , where are given. (In particular, the parking time will not be negative, so we guarantee .)
Explanation of consecutive empty spaces: for example, in the figure below, the position pointed to by the arrow has consecutive empty space on the left and consecutive empty spaces on the right.

Please determine the parking position for each car in order, so that the total time to park all cars is minimized.
Input Format
The first line contains an integer .
The next three lines each contain integers. In the first of these lines, the -th number gives ; in the second line, the -th number gives ; in the third line, the -th number gives . It is guaranteed that and .
Output Format
Output one number, the minimum total time required.
3
18 20 22
1 2 3
1 4 3
54
Hint
Sample Explanation 1
The first car parks in the -rd parking space from left to right. At this time, there are consecutive empty spaces on the left of this space and no consecutive empty spaces on the right, so the time needed is .
The second car parks in the -st parking space from left to right. At this time, there are no consecutive empty spaces on the left and consecutive empty space on the right, so the time needed is .
The third car parks in the -nd parking space from left to right. At this time, there are no consecutive empty spaces on either side, so the time needed is .
The total time to park all cars is .
Constraints
For all testdata, it is guaranteed that , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号