Cod sursa(job #1630317)

Utilizator gerd13David Gergely gerd13 Data 5 martie 2016 01:10:18
Problema Cele mai apropiate puncte din plan Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define ll long long int
using namespace std;
const ll INF = 0x3f3f3f3f ;
struct unu {
    ll x, y;
} doi[100005];
ll dist(unu a, unu b) {
    return (b.x - a.x) * (b.x - a.x)
           + (b.y - a.y) * (b.y - a.y) ;
}
int N ;
bool cmp(unu a, unu b) {
    return a.x < b.x ;
}
int main() {
    freopen("cmap.in", "r", stdin) ;
    freopen("cmap.out", "w", stdout) ;
    scanf("%d", &N) ;
    for(int i = 1 ; i <= N ; ++ i)
       scanf("%lld%lld\n", &doi[i].x, &doi[i].y) ;

    sort(doi + 1, doi + N  + 1, cmp) ;
    ll big = INF ;
    for(int i = 1 ; i < N ; ++ i)
        for(int j = i + 1 ; j <= i + 7 && j <= N; ++ j)
            big = min(big, dist(doi[i], doi[j]));
    printf("%7lf", sqrt(big)) ;
    return 0;
}