[BZOJ2244]: interceptor missiles (DP + CDQ partition + Fenwick tree)

Topic Portal


Title Description

A country in order to defend against enemy missile attacks, to develop a missile interception system. However, this system has an interceptor missile defective: although it is possible to reach the first rounds arbitrary height, and can be an arbitrary speed of the interceptor missile, but each out of the front shell not be higher than the height of the intercept missile flight speed can not be greater than the previous first serve. One day, the radar picked up incoming enemy missiles. As the system is still in beta, so only a system, and therefore may not intercept all the missiles.
In the case of not intercept all the missiles, of course we want to choose the country with minimal loss, which is the largest number of program to intercept missiles. But the number of interceptor missiles most likely to have multiple solutions, if there are multiple optimal solution, then we will randomly select a final interceptor missiles as a blueprint for action.
We spy has gained height and speed of all enemy missiles, your task is to calculate the probability in the implementation of the above decision, each missile was blocked off.


 

Input Format

The first line contains a positive integer $ n $, represents the number of enemy missiles;
bottom row sequence shows all enemy missiles information:
first $ i + 1 $ 2 $ $ line contains two positive integers H_i $ $ $ and $ V_I , respectively, the height and speed of the $ i $ missiles.


 

Output Format

Comprising two output lines.
The first line a positive integer representing the number of the missile up to intercept out;
second line contains $ n-$ a $ 0 $ to a real number between $ 1 $, the $ I $ digit represents $ I $ missiles intercepted off the probability (you can leave any number of significant digits).


 

Sample

Sample input

4
3 30
4 40
6 60
3 30

Sample Output

2
0.33333 0.33333 0.33333 1.00000


 

Data range and tips

For the data of $ 100% $ a, $ 1 \ leqslant n \ leqslant 5 \ times 10 ^ 4 $, $ 1 \ leqslant h_i $, $ v_i \ leqslant 10 ^ 9 $;
uniformly distributed data about $ 30% $ all $ V_I $ They are equal.
Data uniformly distributed about $ 50% $ meet $ 1 \ leqsnalt h_i, v_i \ leqslant 1,000 $.


 

answer

Guess you like

Origin www.cnblogs.com/wzc521/p/11289918.html