#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[100005], b[100005];
int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> n;
for (int i = 0; i < n + n; i++) cin >> a[i] >> b[i];
sort(a, a + n + n);
sort(b, b + n + n);
int ans = 0;
for (int i = 0; i < n + n; i++) {
ans += abs(a[i] - (i / 2 + 1));
ans += abs(b[i] - (i / n + 1));
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |