CF617C.Watering Flowers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A flowerbed has many flowers and two fountains.

You can adjust the water pressure and set any values r1(r1>=0)r_{1}(r_{1}>=0) and r2(r2>=0)r_{2}(r_{2}>=0) , giving the distances at which the water is spread from the first and second fountain respectively. You have to set such r1r_{1} and r2r_{2} that all the flowers are watered, that is, for each flower, the distance between the flower and the first fountain doesn't exceed r1r_{1} , or the distance to the second fountain doesn't exceed r2r_{2} . It's OK if some flowers are watered by both fountains.

You need to decrease the amount of water you need, that is set such r1r_{1} and r2r_{2} that all the flowers are watered and the r12+r22r_{1}^{2}+r_{2}^{2} is minimum possible. Find this minimum value.

输入格式

The first line of the input contains integers nn , x1x_{1} , y1y_{1} , x2x_{2} , y2y_{2} ( 1<=n<=20001<=n<=2000 , 107<=x1,y1,x2,y2<=107-10^{7}<=x_{1},y_{1},x_{2},y_{2}<=10^{7} ) — the number of flowers, the coordinates of the first and the second fountain.

Next follow nn lines. The ii -th of these lines contains integers xix_{i} and yiy_{i} ( 107<=xi,yi<=107-10^{7}<=x_{i},y_{i}<=10^{7} ) — the coordinates of the ii -th flower.

It is guaranteed that all n+2n+2 points in the input are distinct.

输出格式

Print the minimum possible value r12+r22r_{1}^{2}+r_{2}^{2} . Note, that in this problem optimal answer is always integer.

输入输出样例

  • 输入#1

    2 -1 0 5 3
    0 2
    5 2
    

    输出#1

    6
    
  • 输入#2

    4 0 0 5 0
    9 4
    8 3
    -1 0
    1 4
    

    输出#2

    33
    

说明/提示

The first sample is ( r12=5r_{1}^{2}=5 , r22=1r_{2}^{2}=1 ): The second sample is ( r12=1r_{1}^{2}=1 , r22=32r_{2}^{2}=32 ):

首页