Choose when to leave and how fast to ride within T minutes to minimize trip rain plus sweat that grows with the square of speed.
Medium7MathPrefix sumIntervalsNo attempts yetTime limit5sMemory limit256 MBYou are about to leave the university for home, and dark clouds are packed in the distance. You are on a bicycle, so rain soaks you, and racing home soaks you with sweat instead.
A rain radar gives you the predicted rainfall for every minute of the next few hours, you know the latest time you want to be home, and you have already measured how much you sweat at a given speed. One question is left. How do you get home as dry as possible?
The rain is given per one-minute interval in millilitres. Riding through the whole of the i-th minute interval, counted from 0, makes you ri millilitres wet. Your departure and arrival times do not have to fall on whole minutes, and when you cover only a fraction of an interval, only that fraction of its rain hits you. Sweat makes you wet at a rate of s=cv2 millilitres per minute while you ride at speed v in km/h, where c is a positive constant you have measured.
Home is d kilometres away and you have to be there within T minutes from now. Inside that limit you choose when to leave and how fast to ride, and you may change speed on the way. From the moment you leave until you arrive you are outside, so you take all the rain that falls in between. What is the smallest total amount of rain and sweat you can get wet by?
The first line contains an integer T (0<T≤10000), the number of minutes from now by which you have to be home.
The second line contains two real numbers c (0.01≤c≤10), the constant that determines your sweating, and d (1≤d≤50), the distance from the university to home in kilometres.
Each of the next T lines contains an integer ri (0≤ri≤100), the millilitres of rain during the i-th minute interval, counted from 0.
Print on one line the smallest total amount of rain and sweat you can get wet by, in millilitres. Round it to six digits after the decimal point and always print all six of those digits, padding with zeros when needed.