You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
533 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
int x[N], y[N];
int n, res;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
sort(y, y + n);
sort(x, x + n);
for (int i = 0; i < n; i++) res += abs(y[i] - y[n / 2]); // 对与x轴的一条平等线的最短距离和
for (int i = 0; i < n; i++) x[i] -= i;
sort(x, x + n);
for (int i = 0; i < n; i++) res += abs(x[i] - x[n / 2]);
// 输出
cout << res << endl;
return 0;
}