#include "shoes.h"
#include <math.h>
long long count_swaps(std::vector<int> s)
{
int n = s.size();
if (n == 2)
{
if (s[0] == -1)
return 0;
}
else
{
long long swaps = 0;
int k = 0;
for (int i = 0; i < n; i++)
{
if (s[i] == -1)
{
int target = 2 * k;
swaps += abs(i - target);
k++;
}
}
return swaps;
}
return 1;
}
| # | 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... |