Pagini recente » Cod sursa (job #3146827) | Cod sursa (job #377435) | Cod sursa (job #17154) | Infoarena Monthly 2014 - Runda 3 | Cod sursa (job #2900618)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream in("tribute.in");
ofstream out("tribute.out");
int dx, dy, n;
vector<int> x, y;
int main()
{
in>>n>>dx>>dy;
int a, b;
for(int i=0; i<n; i++)
{
in>>a>>b;
x.push_back(a);
y.push_back(b);
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
int dr=n-1, st=0, rez=0;
while(x[dr]-x[st]>dx){
rez+=x[dr--]-x[st++]-dx;
}
dr=n-1, st=0;
while(y[dr]-y[st]>dy){
rez+=y[dr--]-y[st++]-dy;
}
out<<rez;
return 0;
}