# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
297359 | Saboon | Arranging Shoes (IOI19_shoes) | C++17 | 278 ms | 26740 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;
map<int,set<int>> S;
long long count_swaps(vector<int> a){
vector<pair<int,int>> Joft;
for (int i = 0; i < a.size(); i++){
int x = a[i];
if (!S[-x].empty()){
Joft.push_back({*S[-x].begin(),i});
S[-x].erase(S[-x].begin());
}
else
S[x].insert(i);
}
sort(Joft.begin(), Joft.end());
long long ret = 0;
int now = 0;
for (int i = 0; i < a.size(); i+=2){
int v = Joft[now].first, u = Joft[now].second;
now ++;
if (a[v] > a[u])
ret += 2;
ret += abs(i-v);
ret += abs(i+1-u);
}
return ret/2;
}
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... |