This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, x[200200], y[200200], c[100100][2];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i=1;i<=n+n;i++) cin >> x[i] >> y[i];
ll ans = 0, c1 = 0;
for(int i=1;i<=n+n;i++) {
int D = min(max(x[i], 1), n);
ans += abs(D-x[i]);
if(y[i] >= 2) {
c[D][0]++, c1++;
ans += y[i]-2;
} else {
c[D][1]++;
ans += 1-y[i];
}
}
ll S = 0;
for(int i=1;i<=n;i++) {
S += c[i][0]+c[i][1]-2;
ans += abs(S);
}
cout << ans + abs(c1-n);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |