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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll count_swaps(vector<int> s)
{
const ll N = s.size() / 2;
vector<int> l(N), r(N);
int lc = 0;
int rc = 0;
for (int i = 0; i < 2*N; i++)
{
if (s[i] < 0)
l[lc++] = i;
else
r[rc++] = i;
}
ll res = 0; int pos = 0;
for (int i = 0; i < N; i++)
{
if (l[i] > pos)
res += l[i] - pos;
pos += 2;
}
pos = 1;
for (int i = 0; i < N; i++)
{
if (r[i] > pos)
res += r[i] - pos;
pos += 2;
}
return res;
}
# | 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... |