Submission #867393

#TimeUsernameProblemLanguageResultExecution timeMemory
867393lolismekArranging Shoes (IOI19_shoes)C++14
10 / 100
0 ms428 KiB
#include "shoes.h" #define pii pair <int, int> using namespace std; long long count_swaps(vector<int> s){ int n = (int)s.size(); for(int i = 0; i < n; i++){ if(s[i] < 0){ s[i] = -1; }else{ s[i] = +1; } } long long ans = 0; vector <pii> St; for(int i = 0; i < n; i++){ if(!St.empty() && St.back().first == -s[i]){ ans += (i - St.back().second - (St.back().first < s[i])); St.pop_back(); }else{ St.push_back({s[i], 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...