Pagini recente » Cod sursa (job #3260385) | Cod sursa (job #2943628) | Cod sursa (job #1429447) | Cod sursa (job #2436688) | Cod sursa (job #2901055)
#include <bits/stdc++.h>
using namespace std;
ifstream f("tribute.in");
ofstream g("tribute.out");
const int N = 5e4 + 1;
int n, dx, dy, dreptx, drepty, ans; // coltul stanga jos
int x[N], y[N], xs[N], ys[N];
int main(){
f >> n >> dx >> dy;
for(int i = 0; i < n; i++){
f >> x[i] >> y[i];
xs[i] = x[i];
ys[i] = y[i];
}
f.close();
sort(xs, xs + n);
sort(ys, ys + n);
dreptx = xs[n / 2] - dx;
drepty = ys[n / 2];
for(int i = 0; i < n; i++){
if(x[i] > dreptx + dx || x[i] < dreptx)
ans += min(abs(x[i] - dreptx), abs(x[i] - dreptx - dx));
if(y[i] > drepty + dy || y[i] < drepty)
ans += min(abs(y[i] - drepty), abs(y[i] - drepty - dy));
}
g << ans << '\n';
}