Submission #1034226

#TimeUsernameProblemLanguageResultExecution timeMemory
1034226nickolasarapidisArranging Shoes (IOI19_shoes)C++17
0 / 100
1 ms348 KiB
//#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll count_swaps(vector<int> S){ int N = S.size(); map<int, priority_queue<int>> m; for(int i = 0; i < N; i++){ m[S[i]].push(-i); } ll ans = 0; for(int i = 0; i < N; i++){ if(S[i] < 0){ ans += -m[S[i] + 2*S[i]].top() - i + 1; } else{ ans += -m[S[i] + 2*S[i]].top() - i; } } return ans; } /*int main(){ cout << count_swaps({2, 1, -1, -2}); return 0; }*/
#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...