406556: GYM102439 J Boedium

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Boediumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Andrew loves to watch biathlon races, and, like many other fans, he loves the red-haired Josya. For many years of watching the races Andrew has collected enough statistics about each biathlete in the upcoming race. Now he wants to calculate the probability that Josya will be on the podium in the upcoming individual race, and asks you for help.

The individual race consists of $$$5$$$ laps and $$$4$$$ shooting lanes ($$$2$$$ shootings from prone position and $$$2$$$ shootings from standing position). There are $$$5$$$ rounds and $$$5$$$ targets at each shooting stage. Each miss adds one minute to the athlete's time.

We have some information about each biathlete. We know the lap time, as well as the probability to hit the target from the prone and standing position. For simplicity let us consider that all athletes spend the same amount of time on the shooting late. Josya starts at the first number.

At the end of the race, the athlete takes the place of $$$X$$$, equal to the number of athletes who ran the race strictly faster, plus one. All the athletes who took first, second or third place will be on the podium. Note that several athletes can share the one place.

Input

The first line contains one integer $$$n$$$ — number of participants in the race.

In each of the following $$$n$$$ lines there are three numbers $$$time_i, down_i, up_i$$$, where $$$time_i$$$ is the integer lap time in seconds, $$$down_i$$$ is the probability to hit the target from the prone position, $$$up_i$$$ is the probability to hit the target from the standing position. $$$up_i$$$ and $$$down_i$$$ are real numbers with exactly three digits after the decimal point.

$$$$$$1 \leq n \leq 50000$$$$$$ $$$$$$1 \leq time_i \leq 600$$$$$$ $$$$$$0 \leq down_i, up_i \leq 1$$$$$$

Output

Output the only real value — probability of Josya to get on the podium. The absolute or relative error must not exceed $$$10^{-9}$$$.

ExampleInput
4
45 0.700 0.700
60 0.800 0.800
90 0.900 0.900
120 1.000 1.000
Output
0.675394632273

加入题单

上一题 下一题 算法标签: