士兵

 

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int N = 10010;
 4 int n;
 5 int px[N], py[N];
 6 int work(int a[]) {
 7     int res = 0;
 8     sort(a, a + n);
 9     for (int i = 0; i < n; i++) {
10         res += abs(a[i] - a[i / 2]);
11     }
12     return res;
13 }
14 int main() {
15     cin >> n;
16     for (int i = 0; i < n; i++) {
17         cin >> px[i] >> py[i];
18     }
19     sort(px, px + n);
20     for (int i = 0; i < n; i++) {
21         px[i] -= i;
22     }
23     cout << work(px) + work(py) << endl;
24     return 0;
25 }

 

posted @ 2020-11-24 11:50  kyk333  阅读(50)  评论(0编辑  收藏  举报