# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029336 | ender | Arranging Shoes (IOI19_shoes) | C++14 | 15 ms | 4408 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 <bits/stdc++.h>
using namespace std;
long long count_swaps(std::vector<int> s) {
long long ans = 0;
int cl = 0, cr = 0;
vector<int> l, r;
for(int i = 0; i < s.size(); ++i){
if(s[i] < 0) l.push_back(i);
else r.push_back(i);
}
for(int i = 0; i < s.size(); ++i){
if(i%2 == 0){
if(s[i] > 0){
ans += l[cl] - i;
swap(s[i], s[l[cl]]);
cr++;
}
cl++;
}else {
if(s[i] < 0){
ans += r[cr] - i;
swap(s[i], s[r[cr]]);
cl++;
}
cr++;
}
}
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... |