Submission #1014416

#TimeUsernameProblemLanguageResultExecution timeMemory
1014416KasymKArranging Shoes (IOI19_shoes)C++17
45 / 100
19 ms3264 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long #define ff first #define ss second #define all(v) v.begin(), v.end() ll count_swaps(vector<int> v){ int n = (int)v.size(); ll ans = 0; int ne_ = 1, ne__ = 1; for(int i = 0; i < n; ++i){ ne_ = max(i+1, ne_); ne__ = max(i+1, ne__); if(i&1){ if(v[i] < 0){ while(v[ne_] < 0) ne_++; swap(v[i], v[ne_]); ans += (ne_-i); } } else{ if(v[i] > 0){ while(v[ne__] > 0) ne__++; swap(v[i], v[ne__]); ans += (ne__-i); } } } return ans; }
#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...