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;
int vs[2001];
long long count_swaps(vector<int>s) {
long long n = s.size(),ans = 0;
map<int,set<int>>d;
for(int i = 0; i < n; i++){
int f = -1;
if(d[-s[i]].size()){
f = *d[-s[i]].begin();
d[-s[i]].erase(f);
}
if(f != -1){
int j = i;
while(j != f + 1){
swap(vs[j], vs[j - 1]);
swap(s[j], s[j - 1]);
j--;
ans++;
}
if(s[f] > 0) {
swap(s[f], s[f + 1]);
ans++;
}
vs[f] = vs[f + 1] = 1;
}else{
d[s[i]].insert(i);
}
}
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... |