제출 #775127

#제출 시각아이디문제언어결과실행 시간메모리
775127Sandarach151Arranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size()/2; queue<int> negative[n+1]; queue<int> positive[n+1]; long long ans = 0; for(int i=0; i<2*n; i++){ if(s[i]<0){ if(!positive[-1*s[i]].empty()){ ans+= i-positive[-1*s[i]].front(); positive[-1*s[i]].pop(); } else{ negative[-1*s[i]].push(i); } } else{ if(!negative[s[i]].empty()){ ans+= i-negative[s[i]].front()-1; negative[s[i]].pop(); } else{ positive[s[i]].push(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...