#include "shoes.h"
//#define int long long
long long count_swaps(std::vector<int> s) {
int n = (int)s.size();
std::vector<int> in(n, 1);
long long ans = 0;
for (int i = 0; i < n; i++) {
if (!in[i]) continue;
int bw = 0; int x = -1;
for (int j = i + 1; j < n; j++) {
if (!in[j]) continue;
if (s[j] == -s[i]) {
x = j;
break;
}
bw++;
}
ans += (long long)bw + (long long)((bool)(s[i] > s[x]));
in[x] = 0;
}
return ans;
}
# | 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... |