Pagini recente » Cod sursa (job #3170504) | Cod sursa (job #2216644) | Cod sursa (job #767472) | Cod sursa (job #1252026) | Cod sursa (job #791104)
Cod sursa(job #791104)
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define oo 0x3f3f3f3f
#define mp make_pair
#define pb push_back
#define PIII pair<int, pair<int, int> >
#define f first
#define s second
int N, X, Y;
double ans = 1.0 * oo;
vector<PIII> V;
double dist(PIII one, PIII two)
{
return sqrt((one.s.f - two.s.f) * (one.s.f - two.s.f) + (one.s.s - two.s.s) * (one.s.s - two.s.s));
}
int main()
{
freopen("cmap.in", "r", stdin);
freopen("cmap.out", "w", stdout);
scanf("%i", &N);
for(int i = 0; i < N; i++)
{
scanf("%i %i", &X, &Y);
V.pb(mp(X + Y, mp(X, Y)));
}
sort(V.begin(), V.end());
for(int i = 0; i < N; i++)
for(int j = i + 1; j <= min(i + 7, N - 1); j++)
ans = min(ans, dist(V[i], V[j]));
printf("%lf\n", ans);
return 0;
}