Submission #487152

#TimeUsernameProblemLanguageResultExecution timeMemory
487152M_WArranging Shoes (IOI19_shoes)C++14
10 / 100
45 ms67604 KiB
#include <bits/stdc++.h> using namespace std; queue<int> q[100001]; long long count_swaps(vector<int> S){ int len = S.size(); for(int i = 0; i < len; i++){ if(S[i] > 0) q[S[i]].push(i); } long long ans = 0; for(int i = 0; i < len; i++){ if(S[i] < 0){ if(q[-S[i]].front() < i) ans += (i - q[-S[i]].front()) * 1ll; else ans += (q[-S[i]].front() - i - 1) * 1ll; q[-S[i]].pop(); } } 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...