标签:
#include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<cmath> using namespace std; typedef long long LL; #define N 100010 int n; int x,y; int X[N],Y[N]; LL check(int x,int y) { LL res(0); for (int i=1;i<=n;i++) res+=abs(x-X[i])+abs(y-Y[i]); return res; } int main() { scanf("%d",&n); for (int i=1;i<=n;i++) { scanf("%d%d",&x,&y); X[i]=x+y; Y[i]=x-y; } sort(X+1,X+n+1); sort(Y+1,Y+n+1); x=X[n+1>>1]; y=Y[n+1>>1]; if (~(x ^ y) & 1) printf("%lld\n",check(x,y)>>1); else printf("%lld\n",min(min(check(x+1,y),check(x-1,y)),min(check(x,y+1),check(x,y-1)))>>1); return 0; }
标签:
原文地址:http://www.cnblogs.com/yangjiyuan/p/5762536.html