rt 求大佬捞
code:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3+5,maxm = 5e2+5;
int ans,n,m,pos,a[maxn],f[maxn];
double maxx;
struct Edge {
int x,y;
double value;
bool operator < (const Edge& x) const {
return value > x.value;
}
} res[maxn];
priority_queue<Edge>que;
struct Tree {
int x,y;
void input() {
cin>>x>>y;
}
} tr[maxm];
int qpow(int a) {
return a*a;
}
int dst(Tree a,Tree b) {
return sqrt(qpow(a.x-b.x)+qpow(a.y-b.y));
}
int find(int x) {
return x == f[x] ? x : f[x] = find(f[x]);
}
int main() {
cin>>m;
for(int i = 1; i<=m; i++)cin>>a[i];
cin>>n;
for(int i = 1; i<=n; i++)f[i] = i;
for(int i = 1; i<=n; i++) {
Tree t;
t.input();
for(int j = 1; j<=i; j++) {
Edge e;
e.value = dst(t,tr[j]);
e.x = i;
e.y = j;
que.push(e);
}
}
while(!que.empty()) {
Edge e = que.top();
que.pop();
int fx = find(e.x);
int fy = find(e.y);
if(fx == fy)continue;
f[fx] = fy;
pos++;
res[pos] = e;
}
for(int i = 1; i<=pos; i++) {
maxx = max(maxx,res[i].value);
}
// cout<<maxx;
for(int i = 1; i<=m; i++) {
if(double(a[i])>=maxx) {
ans++;
}
}
cout<<ans;
}