poj1723

#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 10010;

int main()
{
    int x[N], y[N], n;

    while (scanf("%d", &n) == 1)
    {
        for (int i = 0; i < n; i++)
            scanf("%d %d", &x[i], &y[i]);
        sort(x, x + n);
        sort(y, y + n);
        for (int i = 0; i < n; i++)
            x[i] -= i;
        sort(x, x + n);
        int ans = 0;
        for (int i = 0; i < n / 2; i++)
            ans += x[n-i-1] - x[i] + y[n-1-i] - y[i];
        printf("%d\n", ans);
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/wys_NO1/article/details/68068294