Submission #1034230

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