spoj#DPMAX. Dot Product Maximization
Dot Product Maximization
Given two vectors, a = ( xa, ya ), b = ( xb, yb ), their dot product is defined as follows:
dp( a, b ) = xa*xb + ya*yb.
Given N vectors in the plane, find a pair for each of them (among those given in the input) such that the dot product of the vector and its pair is maximal. You may pair a vector with itself too.
Input
The first line of input contains a single integer N ( 1 <= N <= 200000 ).
Each of the next N lines contain a pair of real numbers, xi and yi (0 <= |xi|, |yi| <= 100000), representing the i-th vector. xi and yi will be rounded to 3 decimal places.
Output
Output N lines, i-th one containing the maximal dot product for the i-th vector from the input rounded to 3 decimal places.
Example
Input:
4
0.000 1.000
0.000 2.000
1.000 1.000
0.000 0.000
Output:
2.000
4.000
2.000
0.000
Explanation: Pair the first vector with the second, the second with itself, third with itself or with the second, and the last one with any of them.