# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1145662 | MunkhturErdenebat | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> s) {
int a = s.size();
vector<int> maa(a, 0);
long long h = 0;
for(int i = 0; i < a; i++) {
if(maa[i] == 1) continue;
for(int j = i + 1; j < a; j++) {
if(s[j] + s[i] == 0 && maa[j] == 0) {
g = j;
break;
}
}
for(int j = g - 1; j > i; j--) {
if(maa[j] == 0) h++;
}
if(s[i]>0){
h++;
}
maa[g] = 1;
}
return h;
}