#P1158. Missile Interception System
Missile Interception System
Missile Interception System
After (11) years of quiet preparation, a country has developed a new missile interception system. Each system intercepts any missile that is within its working radius (r); that is, a missile is intercepted if its Euclidean distance to the system is at most (r). Note that when (r=0), the system can only intercept a missile whose position is exactly the same as the system's. However, there is a drawback: each interception system can only have its working radius set once per day, and the daily cost of a system is the square of its working radius. Hence, if the two systems are set to radii (r_1) and (r_2) on a given day, the total cost is (r_1^2 + r_2^2).
On one day, enemy missiles are detected. Because the system is still under testing, only two interception systems are deployed. The positions of the two systems are fixed. Given the coordinates of the two systems and the coordinates of all incoming missiles, your task is to compute the minimum total cost ((r_1^2 + r_2^2)) required to intercept all missiles. A missile is intercepted if it lies within at least one system's coverage (i.e. within its working radius).
inputFormat
Input is given in multiple lines:
- The first line contains an integer (n) ((1 \le n \le 10^5)), the number of enemy missiles.
- The second line contains two integers (x_1) and (y_1), the coordinates of the first interception system.
- The third line contains two integers (x_2) and (y_2), the coordinates of the second interception system.
- Each of the next (n) lines contains two integers (x) and (y), representing the coordinates of an incoming missile.
outputFormat
Output a single integer, which is the minimum total cost (r_1^2 + r_2^2) required to intercept all missiles.
sample
3
0 0
10 0
0 0
5 0
10 0
25