Cod sursa(job #2100576)

Utilizator miguelMihail Lavric miguel Data 5 ianuarie 2018 20:44:00
Problema Cele mai apropiate puncte din plan Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 1.03 kb
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define pb push_back
const ll mod = 1e9 + 7;
int n;
map <int, int> m;
vector <pair<int, int>> v;
int x, y;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    ifstream fin("cmap.in");
    ofstream fout("cmap.out");
    //int x; cin>>x; cout<<fixed<<setprecision(11)<<(long double)sqrt(x);
    fin>>n;
    for(int i=0; i<n; i++){fin>>x>>y; v.pb(make_pair(x, y));}
    sort(v.begin(), v.end()); long double d=1000000000000;
    for(int i=0; i<n-1; i++){
            if((long double)sqrt((v[i].first-v[i+1].first)*(v[i].first-v[i+1].first)+(v[i].second-v[i+1].second)*(v[i].second-v[i+1].second))<d)
                d=(long double)sqrt((v[i].first-v[i+1].first)*(v[i].first-v[i+1].first)+(v[i].second-v[i+1].second)*(v[i].second-v[i+1].second));
               } fout<<fixed<<setprecision(11)<<d;
}