题目描述
Problem Description
Snuke is running a hurdle race on a number line. The starting point is at coordinate $0$ and the goal is at coordinate $L$. There are $N$ hurdles on the number line, and the $i$-th hurdle from the left is at coordinate $x_i$ ($0 < x_1 < x_2 < \cdots < x_N < L$).
Snuke can repeatedly choose and perform one of the following three actions:
- Action 1: Run forward a distance of $1$.
- Action 2: Run forward a distance of $0.5$, jump forward a distance of $1$, and then run forward another distance of $0.5$. This totals a distance of $2$.
- Action 3: Run forward a distance of $0.5$, jump forward a distance of $3$, and then run forward another distance of $0.5$. This totals a distance of $4$.
Snuke moves at a speed of $T_1$ seconds per distance $1$ while running, and $T_2$ seconds per distance $1$ while jumping. However, if Snuke is not jumping and is at coordinate $x$ where there is a hurdle, it takes an additional $T_3$ seconds to pass that point. $T_1, T_2, T_3$ are all even numbers.
Find the minimum number of seconds Snuke takes to pass coordinate $L$. (If Snuke jumps through coordinate $L$, the time until he passes coordinate $L$ while jumping is considered the time to pass coordinate $L$.) The answer can be proven to be an integer.
Input Format
The input is given from the standard input in the following format:
$ N $ $ L $ $ x_1 $ $ x_2 $ $\cdots$ $ x_N $ $ T_1 $ $ T_2 $ $ T_3 $
Output Format
Output the minimum number of seconds Snuke takes to pass coordinate $L$ as an integer. (The answer can be proven to be an integer.)
Sample Input and Output
Sample Input #1
2 5
1 4
2 2 20
Sample Output #1
10
Sample Input #2
4 5
1 2 3 4
2 20 100
Sample Output #2
164
Sample Input #3
10 19
1 3 4 5 7 8 10 13 15 17
2 1000 10
Sample Output #3
138
Notes/Hints
Constraints
- All inputs are integers.
- $2 \leq L \leq 10^5$
- $1 \leq N < L$
- $0 < x_1 < x_2 < \cdots < x_N < L$
- $2 \leq T_1, T_2, T_3 \leq 1000$
- $T_1, T_2, T_3$ are even numbers.
Sample Explanation 1
There are hurdles at coordinates $1$ and $4$. The optimal actions are as follows:
1. Perform Action 2. The running distance is $1$, and the jumping distance is $1$, so it takes a total of $2 \times 1 + 2 \times 1 = 4$ seconds.
2. Perform Action 1. It takes $2$ seconds.
3. Perform Action 3. In the middle of the action, Snuke reaches coordinate $L=5$, with a running distance of $0.5$ and a jumping distance of $1.5$, so it takes a total of $2 \times 0.5 + 2 \times 1.5 = 4$ seconds.
This is optimal, and it totals $4 + 2 + 4 = 10$ seconds, so output $10$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分