比赛 |
防止颓废的小练习v0.2 |
评测结果 |
AAAAAAAAAA |
题目名称 |
导弹拦截 |
最终得分 |
100 |
用户昵称 |
KZNS |
运行时间 |
0.105 s |
代码语言 |
C++ |
内存使用 |
1.81 MiB |
提交时间 |
2016-10-18 10:05:30 |
显示代码纯文本
//KZNS
#include <cstdio>
#include <algorithm>
using namespace std;
#define Nmax 100003
int pls[Nmax][2];
int x1, y1, x2, y2;
int N;
int v[Nmax];
int ls[Nmax];
inline bool cmp(const int &a, const int &b) {
return v[a] < v[b];
}
int main() {
freopen("missile2.in", "r", stdin);
freopen("missile2.out", "w", stdout);
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d %d", &pls[i][0], &pls[i][1]);
v[i] = (pls[i][0] - x1) * (pls[i][0] - x1) + (pls[i][1] - y1) * (pls[i][1] - y1);
ls[i] = i;
}
sort(ls, ls+N, cmp);
int mx2 = 0;
int ans = 0x7fffffff;
int u;
for (int i = N-1; i >= 0; i--) {
u = ls[i];
ans = min(ans, mx2 + v[u]);
mx2 = max(mx2, (pls[u][0] - x2) * (pls[u][0] - x2) + (pls[u][1] - y2) * (pls[u][1] - y2));
}
ans = min(ans, mx2);
printf("%d\n", ans);
return 0;
}
//UBWH