# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303557 | vipghn2003 | 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<bits/stdc++.h>
#include "shoes.h"
using namespace std;
const int N=1e5+5;
int n;
int count_swaps(vector<int>a)
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
n=a.size();
int res=0;
for(int i=0;i<n;i+=2)
{
int id;
for(int j=2;j<=n;j++)
{
if(a[j]==-a[i])
{
id=j;
break;
}
}
for(int j=id;j>i+1;j--)
{
res++;
swap(a[j],a[j-1]);
}
if(a[i]>0) res++;
}
cout<<res;
}