https://ac.nowcoder.com/acm/problem/16601
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
/*
1、为什么要求是系统2最大值于系统1当前的那颗导弹求最小
因为最大值就说明系统二可以覆盖所有的点
通过第二个系统来为第一个(总)系统减轻负担
*/
struct node{
ll x,y;
ll d1,d2;
};
node b[100005];
ll x1,y11,x2,y2,n;
bool cmp(node a,node b){
return a.d1>b.d1;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin>>x1>>y11>>x2>>y2;
cin>>n;
node a;
ll cnt1 = 1,cnt2 = 1;
for(int i = 1; i <= n; i++){
cin>>b[i].x>>b[i].y;
b[i].d1 = (b[i].x - x1)*(b[i].x - x1) + (b[i].y-y11)*(b[i].y-y11);
b[i].d2 = (b[i].x - x2)*(b[i].x - x2) + (b[i].y-y2)*(b[i].y-y2);
}
sort(b+1,b+n+1,cmp);
ll ma = b[1].d2;
ll ans = b[1].d1;
for(int i = 2; i <= n+1; i++){
ma = max(ma,b[i-1].d2);
ans = min(ans,ma+b[i].d1);
//cout<<ans<<endl;
}
cout<<ans<<endl;
return 0;
}