Cod sursa(job #2484386)

Utilizator MoodyFaresFares Mohamad MoodyFares Data 31 octombrie 2019 01:40:51
Problema Tribute Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAX_N = 50000;

int xCoord[MAX_N];
int yCoord[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 = 0; i < n; i++)
    scanf("%d%d", &xCoord[i], &yCoord[i]);

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

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

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