# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1204047 | arkanefury | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 0 KiB |
#include "shoes"
using namespace std;
const int N = 2e5+5;
int a[N], b[N];
int64 count_swaps(vector<int>v){
int n = v.size();
for(int i = 0; i < n; i ++){
if(v[i] > 0)a[v[i]] = i;
else b[v[i] * -1] = i;
}
int ans = 0, x = 0;
for(int i = 1; i <= n/2; i ++){
ans += a[i] - x + b[i] - x - 1;
x += 2;
}
return ans;
}