Crossing the River
Time limit1sMemory limit256 MB
Pick a booster range and rock hops that cross the river with the lowest range-squared plus per-jump cost.
Problem
Doctor Nefario is leaving on a trip after a long stretch of work in his lab. On the way he has to cross a river. The river holds rocks laid out on a straight line to the far bank, and he can use them as stepping stones. The width of the river, meaning the whole distance he has to cover, is .
The doctor's scooter hovers but cannot jump far, so a longer jump needs a rocket booster. A booster costs more when it is stronger. A booster that jumps up to distance costs . The booster works any number of times, but every jump costs another . For example, a booster of range used for five jumps costs in total.
He starts on the near bank at distance and finishes on the far bank at distance . One jump moves him forward by at most , and he must land on a rock or on the far bank.
Given the width , the cost of one jump, and the positions of the rocks, find the minimum cost of crossing the river, the number of jumps it takes, and the booster range .

In the figure the doctor crosses a river of width . The rocks sit at distances , , , and . A booster of range carries him across in two jumps.
The limits are , , and . A rock position is an integer greater than and less than . The range is chosen as a positive integer. The values grow large enough to need 64-bit integers, and scanning every possible range does not fit in the time limit.
Input
The input holds several test cases. The first line of each test case has the integers , , and : the width of the river, the cost of one jump, and the number of rocks. Each of the next lines holds the position of one rock. The rocks are not always listed in order of position. The last line holds a single , and the input ends on that line.
Output
For each test case print the minimum cost of crossing the river on one line, in this format.
Minimum cost M achieved with J jumps of range R
is the minimum cost, is the range that reaches it, and is the smallest number of jumps needed to cross with range . When several ranges reach the minimum cost, print the smallest of them as .