# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915973 | Aiperiii | Arranging Shoes (IOI19_shoes) | C++14 | 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;
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
long long count_swaps(std::vector<int> s) {
int x=abs(s[0]);
set <int> v;
for(int i=0;i<s.size();i++){
if(s[i]==-x && i%2==1)v.insert(i);
}
int ans=0;
for(int i=0;i<s.size();i++){
if(i%2==0 && s[i]==x){
auto it=v.upper_bound(i);
ans+=(*it-i);
v.erase(it);
}
}
return ans;
}