Cod sursa(job #1969738)

Utilizator tifui.alexandruTifui Ioan Alexandru tifui.alexandru Data 18 aprilie 2017 17:08:15
Problema Cele mai apropiate puncte din plan Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <bits/stdc++.h>
#define ll long long
#define Nmax 100005
#define INF 4e18
#define x first
#define y second
#define tip pair<ll,ll>
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
tip v[Nmax];
inline ll get_dist(const tip &a, const tip &b)
{
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
int main()
{int n;
f>>n;
for(int i=1;i<=n;i++)
    f>>v[i].x>>v[i].y;
sort(v+1,v+n+1);
ll sol=get_dist(v[1],v[2]);
for(int i=1;i<=n;i++)
    for(int j=i-1;j>0 and v[i].x-v[j].x<sol;j--)
    {
        ll dist=get_dist(v[j],v[i]);
        sol=min(sol,dist);
    }
g<<fixed<<setprecision(6)<<sqrt(sol);

    return 0;
}