Cod sursa(job #2484388)

Utilizator MoodyFaresFares Mohamad MoodyFares Data 31 octombrie 2019 01:44:20
Problema Tribute Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N = 50000;

int xCoord[1 + MAX_N];
int yCoord[1 + MAX_N];

int main() {
  freopen("tribute.in", "r", stdin);
  freopen("tribute.out", "w", stdout);

  int n, dx, dy;

  scanf("%d%d%d", &n, &dx, &dy);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &xCoord[i], &yCoord[i]);

  sort(xCoord + 1, xCoord + n + 1);
  sort(yCoord + 1, yCoord + n + 1);

  int ans = 0;
  for (int i = 1; i <= n / 2; i++) {
    ans += max(xCoord[n - i + 1] - xCoord[i] - dx, 0);
    ans += max(yCoord[n - i + 1] - yCoord[i] - dy, 0);
  }

  printf("%d", ans);
  return 0;
}