#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll count_swaps(vector<int>Shoes) {
vector<int>ShoesQueue = Shoes;
int SameSizeAnswer = 0;
int c1 = 0;
int c2 = 0;
ll cnt = 0;
for (int i = 0; i < ShoesQueue.size(); i++)
{
int Shoe = ShoesQueue[i];
if (Shoe < 0)
{
cnt += abs(i - c1 * 2);
c1++;
}
else if (Shoe > 0 )
{
cnt += abs(i - c2 * 2 - 1);
c2++;
}
}
SameSizeAnswer = cnt / 2;
return SameSizeAnswer;
}
| # | 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... |