Pagini recente » Cod sursa (job #2988153) | Cod sursa (job #1042900) | Cod sursa (job #1438753) | Cod sursa (job #1413485) | Cod sursa (job #2468000)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin( "tribute.in" );
ofstream fout( "tribute.out" );
const int NMAX = 50000;
int x[NMAX + 1], y[NMAX + 1];
int main() {
int n, st, dr, sol, i;
fin >> n >> st >> dr;
for( i = 1; i <= n; ++i )
fin >> x[i] >> y[i];
sort( x + 1, x + n + 1 );
sort( y + 1, y + n + 1 );
sol = 0;
for( i = 1; i <= n; ++i ){
sol += max(0, x[i + 1] - x[n - i] - st); //subsecventa de suma maxima
sol += max(0, y[i + 1] - y[n - i] - dr);
}
fout << sol;
return 0;
}