409767: GYM103736 H Optimal Biking Strategy

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Optimal Biking Strategytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Alice is going to go to the supermarket, which is $$$p$$$ meters away from her. She can walk or ride a bike. There are $$$n$$$ bike stops on the road, and she can only get on and off at these stops if she rides a bike.

She needs to pay to ride a bike. One yuan allows riding at most $$$s$$$ meters(less than $$$s$$$ meters costs one yuan, too). Formally, if two stops are $$$x$$$ meters away from each other and Alice chooses to bike, it costs her $$$\lceil\frac{x}{s}\rceil$$$ yuan.

Now, she has $$$k$$$ yuan, and she wants to know, what is the minimum number of meters to walk.

Input

The first line contains three integers $$$n, p, s$$$ $$$(1 \le n \le 10^6, 1 \le p \le 10^9,1\le s \le 10^9)$$$ indicating the number of the bike shops, the location of the store, and maximum meters that one yuan allows to ride.

The second line contains $$$n$$$ integers, $$$a_1, a_2, \cdots, a_n$$$ $$$(0 \le a_i \le p)$$$ indicating the position of the $$$i$$$-th stop ($$$\forall i< j, a_i< a_j$$$).

The third line contains an integer $$$k(1\le k \le 5)$$$, indicating Alice has $$$k$$$ yuan.

Output

Output one line containing one integer indicating the minimum number of meters that Alice needs to walk.

ExamplesInput
1 10 10
2
5
Output
10
Input
3 100 10
80 99 100
2
Output
80
Input
4 10 3
1 2 6 7
1
Output
9
Note

In the first test case, Alice cannot find any other bike stops to get off, so she has to walk $$$10$$$ meters.

In the second test case:

Alice can walk $$$80$$$ meters and then pay two yuan to ride $$$20$$$ meters.

In the third test case, Alice can only ride from $$$1$$$ to $$$2$$$ or $$$6$$$ to $$$7$$$, so she has to walk the remaining $$$9$$$ meters.

加入题单

算法标签: