Instead of wasting your time with my own explanation of the Problem, here is the link, https://www.codechef.com/CDX2018/problems/CODX02

What I have done is that I took T as total required time , now, T = t1 + t2 + t3 where t1 is time from pos1 to pos2 and so on ( if we check the sample test case ), now t1 = ( pos2 — pos1 )/v1 where v1 = initial velocity , pos1 = initial position = 0 , pos2 = second position, similarly t2 = ( pos3 — pos2 )/v2 , where v2 is new velocity after the force on second position so v2 velocity from pos2 to pos3 , and so on , now v2 = v1 + f1 , v3 = v2 + f2 = ( v1 + f1 ) + f2 . so our equation for sample test case becomes T = ( pos2 — pos1 )/v1 + ( pos3 — pos2 )/( v1 + f1 ) + ( pos4 — pos3 )/( v1 + f1 + f2).

since we have to find the initial velocity v1, now here is the hope that we know T, we know the difference of positions and we know forces, we only need to transform this equation so that v1 comes left, but I am stuck at how to do this.

Am I doing right or there is another better approach to solve this problem?