实际就是求,图的生成树中最大边最小
实际上还是最小瓶颈生成树
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,t[505],tot;
int x[1055],y[1055],fa[1055];
struct aa
{
int x,y;
double dis;
bool operator <(const aa &b) const
{
return dis<b.dis;
}
}bian[1000005];
int find(int x)
{
return fa[x]==x ? x : fa[x]=find(fa[x]);
}
int main()
{
scanf("%d",&m);
for (int i=1;i<=m;i++) scanf("%d",&t[i]);
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]);
for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
{
double
dis=sqrt((x[i]-x[j])*(x[i]-x[j])*1.0+(y[i]-y[j])*(y[i]-y[j])*1.0);
bian[++tot].x=i;bian[tot].y=j;bian[tot].dis=dis;
}
sort(bian+1,bian+tot+1);
for (int i=1;i<=n;i++) fa[i]=i;
int j=0,kk;
for (int i=1;i<=tot;i++)
{
int fx=find(bian[i].x);
int fy=find(bian[i].y);
if (fx==fy) continue;
else
{
j++;
fa[fx]=fy;
if (j==n-1)
{
kk=bian[i].dis;
break;
}
}
}
int ans=0;
for (int i=1;i<=m;i++)
if (t[i]>=kk) ans++;
printf("%d",ans);
return 0;
}