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<bits/stdc++.h>
#include "shoes.h"
using namespace std;
long long count_swaps(std::vector<int> v) {
int n = v.size();
long long ans = 0;
vector<int>l, r, idx(n / 2);
for (int i = 0; i < n; i++)
v[i] > 0 ? r.push_back(i) : l.push_back(i);
for (int i = 0; i < n / 2; i++) {
int dif = abs(l[i] - r[i]) - 1;
ans += dif;
if (l[i] > r[i])
ans++;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |