# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751347 | kusmetliq | Arranging Shoes (IOI19_shoes) | C++14 | 1081 ms | 11548 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(vector<int> a) {
int n=a.size()/2;
long long ans=0;
while(a.size()>0) {
map<int,int>m;
for(int i=0;i<a.size();i++) {
if(m[a[i]]==0)m[a[i]]=i+1;
}
int minscore=2*n;
int scoreval=0;
for(int i=1;i<=n+69;i++) {
if(m[i]==0)continue;
int updscore=0;
updscore+=m[i]-1;
updscore+=m[-i]-1;
if(m[-i]<m[i])updscore--;
if(updscore<minscore) {
minscore=updscore;
scoreval=i;
}
}
ans+=minscore;
a.erase(find(a.begin(),a.end(),scoreval));
a.erase(find(a.begin(),a.end(),-scoreval));
}
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... |