I have been thinking about this problem for quite some time now but I am stuck and I cannot find a feasible solution for this one. The equation has become really ugly for me and it seems messy. So, please can anyone help me on how to solve this problem? Thanks in advance.

Any help now???

Let

x= (x_{1},x_{2}, ...,x_{n}) represent our solution,x_{i}is the velocity fori-th section (according to the hint, we will always ride with uniform velocity on one section).It only makes sense to consider solutions with

x_{i}>max(0,v_{i}). Also there's always an optimal solution where we use all our energy, because if we have some energy left, we can increase velocity somewhere and we'll arrive faster.Let . We'll consider only solutions satisfying

F(x) = 0 because we want to use all our energy. Let . We want to optimizegwhile respecting the constraintF(x) = 0.Lagrange multipliers tell us that for optimal solution there exists some λ, such that , so for every

iwe havex_{i}^{2}(x_{i}-v_{i})k_{i}=C(where ).For given

Cwe can solve this equation using binsearch (left side is increasing ifx_{i}>max(0,v_{i}). We can also observe that if we increase C, then the solutionx(C) will also increase and soF(x(C)) will also increase. So we can binsearch for suchCthatF(x(C)) = 0 and this will give us optimalx.