#STICKS. Magic Sticks
Magic Sticks
We have N sticks are lined up in a queue with different distances between them, and each stick is leaning on the left stick (look at figure).
L: the length of the stick.
D: the distance between the stick head point and the left one head point.
We catch the first stick (that length L0) and keep it vertical.
Determine the total time that expected to fall down all sticks if the first stick moved away (assume that each stick's bottom end will not be displaced, and when the stick reach ground it will vanish and the right one start to fall).
You will have V (linear velocity for the head point) at time = 1 second (from the stick start to fall, if we assume that stick will not stop and keeping same motion type).
Suppose that weight force has stable effect on the stick in direction and value.
Input
the first line: N, L0
next N-1 Line: Lk, Dk, Vk(1)
Output
One number T (total time in millisecond).
Example
Input: 2 8.75</p>
10 8.7 25000Output: 2
Constraints
2 <= N <= 5000
1 <= L <= 1000000
1 <= V <= 1000000.