이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
const int N = 100001;
int n, a[2][N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
ll ans = 0;
for(int i = 0 ; i < 2 * n ; i++){
int x, y;
cin >> x >> y;
int nx = min(n, max(1, x));
int ny = min(2, max(1, y));
ans += abs(nx - x) + abs(ny - y);
a[ny - 1][nx - 1]++;
}
int sum = 0;
for(int j = 0 ; j < n - 1 ; j++){
sum += a[0][j] + a[1][j];
int sz = (j + 1) * 2;
ans += abs(sum - sz);
}
sum = 0;
for(int j = 0 ; j < n ; j++){
sum += a[0][j];
}
ans += abs(sum - n);
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |