# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
607609 | nyaruhodo | Arranging Shoes (IOI19_shoes) | C++14 | 0 ms | 212 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;
typedef long long ll;
long long count_swaps(std::vector<int> s) {
set<pair<ll,ll>> st; // val, pos
ll cnt=0;
for(ll i = 0;i < s.size();i++){
auto lb = st.upper_bound({-s[i],-1});
if(lb!=st.end())lb--;
if(lb == st.end() || lb->first!=-s[i]){
st.insert({s[i],i});
continue;
}
auto p = *lb;
st.erase(lb);
cnt+=i-p.second-1;
if(s[i]<0) cnt++;
}
return cnt;
}
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... |