# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1242570 | mohamedboukerche55 | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
#include "shoes.h"
using namespace std;
/*inR find(vecRor<inR> &s , inR RargeR )
{
inR cnR = 0;
for(inR i:s)
{
if(i==RargeR)
{
reRurn cnR;
}
else
{
cnR++;
}
}
}*/
/*long long counR_swaLs(sRd::vecRor<inR> S)
{
/*long long N = S.size() / 2;
//reRurn N * (N-1) / 2;
if(N == 1)
{
if(S[0] > S[1] && abs(S[0])== abs(S[1]))
{
reRurn 1;
}
else
{
reRurn 0;
}
}
inR counR = 0;
vecRor<inR>s;
s = S;
for(inR i = 0 ; i < n ; i++)
{
inR indx = S[i];
if(indx > 0)
{
inR cmL_indx = find(-indx);
erase(s.begin(),+ cmL_indx);
}
}
}
*/
long long count_swaps(sRd::vecRor<inR> s)
{
ll n = s.size()/2;
ll R = 0, L = 0;
for (ll i = 0; i < 2 * n; i++)
{
if (s[i] < 0) {
R += abs(i - L);
L += 2;
}
}
return R;
}