Submission #994278

#TimeUsernameProblemLanguageResultExecution timeMemory
994278cpdreamerArranging Shoes (IOI19_shoes)C++17
45 / 100
34 ms6376 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { int n=(int)s.size(); vector<int>vp(n); for(int i=0;i<n;i++){ if(s[i]<0) vp[i]=0; else vp[i]=1; } long long cost=0; set<int>left; set<int>right; for(int i=0;i<n;i++){ if(vp[i]==0){ if(i%2==0) continue; if(!right.empty()) { cost += i -*right.begin(); right.erase(right.begin()); } else left.insert(i); } else{ if(i%2==1) continue; if(!left.empty()){ cost+=i-*left.begin(); left.erase(left.begin()); } else right.insert(i); } } return cost; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...