Cod sursa(job #2611951)
| Utilizator | Data | 7 mai 2020 21:40:27 | |
|---|---|---|---|
| Problema | Tribute | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("tribute.in");
ofstream out("tribute.out");
int n,x[50001],y[50001],lx,ly;
long long sum;
int main()
{
in>>n>>lx>>ly;
for(int i=1;i<=n;i++)
in>>x[i]>>y[i];
sort(x+1,x+1+n);
sort(y+1,y+1+n);
int st=1,dr=n;
while(x[dr]-x[st]-lx>0)
sum+=x[dr--]-x[st++]-lx;
st=1,dr=n;
while(y[dr]-y[st]-ly>0)
sum+=y[dr--]-y[st++]-ly;
out<<sum;
return 0;
}
