Cod sursa(job #911706)

Utilizator dragangabrielDragan Andrei Gabriel dragangabriel Data 11 martie 2013 20:36:03
Problema Cele mai apropiate puncte din plan Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.64 kb
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,i,j,k;
struct nod
{
	int x;
	int y;
}v[100005];
double rez;

int cmp(const nod a,const nod b)
{
	if (a.x==a.y) return b.x<b.y;
	return a.x<a.y;
}

double calc(int a,int b)
{
	return sqrt((v[a].x-v[b].x)*(v[a].x-v[b].x)+(v[a].y-v[b].y)*(v[a].y-v[b].y));
}

int main()
{
	freopen("cmap.in","r",stdin);
	freopen("cmap.out","w",stdout);
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d %d",&v[i].x,&v[i].y);
	sort(v+1,v+n+1,cmp);
	rez=calc(1,n);
	for (i=1;i<=n;i++)
		for (j=i+1;j<=i+7;j++)rez=min(rez,calc(i,j));
	printf("%6lf\n",rez);
	return 0;
}