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;
long long count_swaps(vector<int> s){
int n = s.size();
map<int,stack<int>> v;
long long ans = 0;
for(int i = 0;i<n;i++){
if(v[-s[i]].size()==0)v[s[i]].push(i);
else{
ans+=(i-v[-s[i]].top()-1);
v[-s[i]].pop();
if(s[i]<0)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... |