Cod sursa(job #2335678)
Utilizator | Data | 4 februarie 2019 13:53:30 | |
---|---|---|---|
Problema | Tribute | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<fstream>
#include<algorithm>
using namespace std;
int x,y,a[50010],b[50010],rez,n;
ifstream cin ("tribute.in");
ofstream cout ("tribute.out");
int main(){
cin >>n>>x>>y;
for (int i = 0; i<n; i++)cin >>a[i]>>b[i];
sort(a,a+n);
sort(b,b+n);
for (int i = 0, j = n-1; j >=0 && i<n; i++, j--){
rez+=max(a[i]-a[j]-x,0);
rez+=max(b[i]-b[j]-y,0);
}
cout << rez;
}