# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
196971 | Basilhijaz | Arranging Shoes (IOI19_shoes) | Java | 0 ms | 0 KiB |
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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(std::vector<int> s) {
int cnt = 0; long long swaps = 0;
for(int i = 0; i < s.size(); i++){
if(s[i] < 0){
swaps += abs(i - (cnt * 2));
for(int j = 0; j < s.size(); j++){
if(s[j] == s[i]*-1){
swaps += abs((cnt+1)*2 - j);
}
if(i > j){
if((cnt+1)*2 > j){
swaps--;
}
else{
swaps++;
}
}
}
cnt++;
}
}
return swaps;
}