2018 Innopolice First Stage, December 1
There is an amazingly equipped hi-tech sauna in Innopolis sport center. However, due to complex techniques were used while building it people are not sure how to maintain it properly.
There are n - 1 consecutive compartments in the sauna. Between each pair of adjacent compartments, there is a stove. There are two more stoves: one connected only to the first compartment, and one connected only to the last, which makes exactly n stoves.
The i-th compartment has volume
ki. Each stove can have from 0 to v stones. Let
pi be the number of stones in thei-th stove, then the i-th compartment receives
pi+1 units of heat.
There are s stove stones in sport center. Sport center management wants to minimize the sum of heat received by all compartments, so the rest of the building would not be heated up, but all stones have to be used as it is a waste to buy them otherwise. Help them solve the problem.
The first line contains three integers n, s and v (2 ≤ n ≤ 1000, 1 ≤ v ≤
105, s ≤ n * v) - number of stoves, number of stones and stove capacity, respectively.
The second line contains n - 1 integers
ki - the volume of the i-th compartment (1 ≤
Print the minimum possible total heat received by all compartments.
In the example the correct answer is achieved if we put four stones into the first and the fourth stove, and two stones into the second. Then the heat in all compartments, except the first, will be zero, and in the first - eight.
4 10 4 1 2 3