# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
965368 | akacool445k | 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 "shoes.h"
long long count_swaps(std::vector<int> s) {
long long n = s.size();
long long ans = 0;
vector<int> c(n, 1);
for (int i = 0; i < n; i++) {
if (c[i] == 0) continue;
int ss = 0;
for (int j = i + 1; j < n; j++) {
if (s[i] + s[j] == 0) {
ans += ss;
c[j] = 0;
break;
} else {
ss += c[j];
}
}
if (s[i] > 0) ans++;
}
return ans;
}