Submission #692483

#TimeUsernameProblemLanguageResultExecution timeMemory
692483zeroesandonesArranging Shoes (IOI19_shoes)C++17
50 / 100
1075 ms3124 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; using ll = long long; using vi = vector<long long>; #define pb emplace_back long long count_swaps(vector<int> s) { int n = (s.size()); ll ans = 0; for(int i = 0; i < n; i += 2) { ll closest = i; for(int j = i + 1; j < n; ++j) { if(s[j] == -s[i]) { closest = j; break; } } for(int j = closest; j > i + 1; --j) { swap(s[j], s[j - 1]); ++ans; } if(s[i] > 0) { swap(s[i], s[i + 1]); ++ans; } } 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...