#include <iostream>
#include <algorithm>
using namespace std;
int n, ans = 0;
struct dis {
int x, y;
} s[100000];
bool xcmp(dis a, dis b) {
return a.x < b.x;
}
bool ycmp(dis a, dis b) {
return a.y < b.y;
}
int main() {
cin.tie(0);
cin >> n;
for (int i = 0; i < n ; ++i)
cin >> s[i].x >> s[i].y;
sort(s, s + n, xcmp);
int advx = s[n / 2].x;
sort(s, s + n, ycmp);
int advy = s[n / 2].y;
for (int i = 0; i < n ; ++i) {
ans += abs(s[i].x - advx);
ans += abs(s[i].y - advy);
}
cout << ans << endl;
return 0;
}
评论区