# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143775 | jwvg0425 | Arranging Shoes (IOI19_shoes) | C++17 | 99 ms | 11512 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"
#include <set>
long long count_swaps(std::vector<int> s) {
std::set<int> minus;
std::set<int> plus;
std::vector<bool> used(s.size(), false);
long long ans = 0;
long long useCount = 0;
for (int i = 0; i < s.size(); i++)
{
if (s[i] > 0)
plus.insert(i);
else
minus.insert(i);
}
for (int i = 0; i < s.size(); i++)
{
if (used[i])
{
useCount--;
continue;
}
if (s[i] > 0)
{
int near = *minus.lower_bound(i);
minus.erase(near);
used[near] = true;
ans += near - i - useCount;
}
else
{
int near = *plus.lower_bound(i);
plus.erase(near);
used[near] = true;
ans += near - i - 1 - useCount;
}
useCount++;
}
return ans;
}
Compilation message (stderr)
# | 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... |