Cod sursa(job #2433390)

Utilizator PredescuSebastianIonPredescu Sebastian Ion PredescuSebastianIon Data 27 iunie 2019 11:02:44
Problema Tribute Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
#include <algorithm>

using namespace std;
ifstream f("tribute.in");
ofstream g("tribute.out");
int n,l1,l2,x[50005],y[50005],sol;
int main()
{
    f>>n>>l1>>l2;
    for(int i=1;i<=n;++i)
    {
        f>>x[i]>>y[i];
    }
    sort(x+1,x+n+1);
    sort(y+1,y+n+1);
    for(int i=0;i<n;++i)
    {
        sol+=max(x[1+i]-x[n-i]-l1,0);
        sol+=max(y[i+1]-y[n-i]-l2,0);
    }
    g<<sol;
    return 0;
}