#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
#define int long long
const int N = (int)1e5+10;
int n;
vector<int> v[N];
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n; int ans = 0;
for(int i = 0; i < 2*n; i++){
int x, y; cin >> x >> y;
v[1].pb(x), v[0].pb(y);
}
for(int j : {0,1}) sort(all(v[j]));
int x = 1;
for(int i = 0; i < 2*n; i++){
if(i<n) ans+=abs(v[0][i])+abs(x-v[1][i]);
else ans+=abs(v[0][i]-1)+abs(x-v[1][i]);
if(i%2) x++;
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |