Cod sursa(job #2190910)

Utilizator Iulia25Hosu Iulia Iulia25 Data 31 martie 2018 23:24:11
Problema Tribute Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
#include <algorithm>

using namespace std;

ifstream fin ("tribute.in");
ofstream fout ("tribute.out");

const int N = 500001;
int a[N], b[N], n, dx, dy, i, j, s;

int main()  {
  fin >> n >> dx >> dy;
  for (i = 1; i <= n; ++i)
    fin >> a[i] >> b[i];
  sort (a + 1, a + n + 1);
  sort (b + 1, b + n + 1);
  for (i = 1, j = n; i <= j; ++i, --j)
    s += max(a[j] - a[i] - dx, 0) + max(b[j] - b[i] - dy, 0);
  fout << s;
}