Cod sursa(job #2013665)

Utilizator tziplea_stefanTiplea Stefan tziplea_stefan Data 21 august 2017 23:59:27
Problema Cele mai apropiate puncte din plan Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define VAL 100005

using namespace std;

ifstream fin("cmap.in");
ofstream fout("cmap.out");

int N, i, j;
double ANS;
pair <double, double> P[VAL];

void Check(pair <double, double> A, pair <double, double> B)
{
    ANS=min(ANS, sqrt((A.first-B.first)*(A.first-B.first)+(A.second-B.second)*(A.second-B.second)));
}

int main()
{
    fin >> N;
    for (i=1; i<=N; i++)
      fin >> P[i].first >> P[i].second;
    sort(P+1, P+N+1);
    ANS=1000000000000;
    for (i=1; i<=N; i++)
      for (j=i+1; j<=i+7; j++)
        Check(P[i], P[j]);
    fout << fixed << setprecision(7) << ANS << '\n';
    fin.close();
    fout.close();
    return 0;
}