Cod sursa(job #976142)

Utilizator Kira96Denis Mita Kira96 Data 22 iulie 2013 16:52:10
Problema Cele mai apropiate puncte din plan Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include<fstream>
#include<cmath>
#include<vector>
#include<algorithm>
#define x first
#define y second
#define NM 100100
#include<iomanip>
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
vector<pair<double,double> >v(NM);
double dist(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 n,i,j;
double d;
int main ()
{
	f>>n;
	
	for(i=0;i<n;++i)
		f>>v[i].x>>v[i].y;
	sort(v.begin(),v.begin()+n-1);
	d=dist(0,n-1);
	for(i=0;i<n;++i)
		for(j=i+1;j<n;++j)
		{
			if(dist(i,j)>d)
				break;
			if(dist(i,j)<d)
				d=dist(i,j);
		}
	g<<fixed<<setprecision(6)<<d;
	return 0;
}