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>
using namespace std;
using ll = long long;
template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; }
template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; }
const int nax = 100100;
ll count_swaps(vector<int> a) {
ll ans = 0;
int n = (int)a.size();
for (int i=0;i<n;i+=2) {
for (int j=i;j<n;j++) {
if (a[j] == -a[i]) {
for (int k=j-1;k>i;k--) {
swap(a[k],a[k+1]);
ans++;
}
break;
}
}
if (a[i] > 0) {
swap(a[i],a[i+1]);
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... |