Cod sursa(job #2047741)

Utilizator AlexPop28Pop Alex-Nicolae AlexPop28 Data 25 octombrie 2017 10:46:26
Problema Tribute Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;
ifstream fin ("tribute.in");
ofstream fout ("tribute.out");

const int nmax = 50001;
int n,dx,dy,x[nmax], y[nmax],rez,i,j;
int main()
{
    fin >> n>>dx>>dy;
    for(i=1;i<=n;i++)
        fin >> x[i]>>y[i];
    sort(x+1,x+n+1);
    sort(y+1,y+n+1);
    i=1; j=n;
    while(i<=j)
    {
        if(x[j]-x[i]-dx > 0)
            rez+=x[j]-x[i]-dx;
        if(y[j]-y[i]-dy>0)
            rez+=y[j]-y[i]-dy;
        i++;
        j--;
    }
    fout << rez <<endl;

}