STICKS - Magic Sticks

no tags 

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
10 8.7 25000 Output: 2

Constraints

2 <= N <= 5000
1 <= L <= 1000000
1 <= V <= 1000000.


hide comments
(Tjandra Satria Gunawan)(曾毅昆): 2013-01-19 14:36:15

@Nipun Poddar: Sorry I can't make spoil here, I can't tell you more case. Read the problem statement carefully, maybe you misunderstand the problem, here I highlight some important rule that maybe you ignored:
1) each stick's bottom head will not displaced
2) wight force has stable effect on the stick in dirction and value
3) when the stick reach ground it will vanish and the right one start to fall
4) that stick will not stop and keeping same motion type
Hope this help you ;-)

Nipun Poddar: 2013-01-19 14:06:11

plz give some more test cases...getting WA :(

Last edit: 2013-01-19 14:06:33
Aditya Pande: 2013-01-14 14:50:02

@olive: you just try to make a program that gives the correct answer for the test case. You can easily infer it....

Sushant Ojal: 2013-01-13 11:11:36

two doubts:
1.) by constant acceleration, is it meant that the motion has constant angular acceleration?
2.) should each of the individual time, be rounded and then added for the output or is the rounding off to be done after the summation of all the times.

Mostafa 36a2: 2013-01-13 07:08:48

@Tjandra Satria Gunawan : yes dear the output should be integer but don't forget to round the number before print it.

(Tjandra Satria Gunawan)(曾毅昆): 2013-01-11 17:05:55

output description is not clear, is the output is integer? if not which precision to print???

omar alkattan: 2013-01-06 16:56:43

@Mostafa 36a2 : the motion has constant acceleration

Mostafa 36a2: 2013-01-06 16:49:06

can you explain this term :
"suppose that wight force has stable effect on the stick in dirction and value"
can you add an image for it please?


Added by:omar alkattan
Date:2013-01-04
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own