제출 #670614

#제출 시각아이디문제언어결과실행 시간메모리
670614birthdaycakeArranging Shoes (IOI19_shoes)C++17
10 / 100
0 ms212 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; int vs[2001]; long long count_swaps(vector<int>s) { long long n = s.size(),ans = 0; map<int,set<int>>d; for(int i = 0; i < n; i++){ int f = -1; if(d[-s[i]].size()){ f = *d[-s[i]].begin(); } if(f != -1){ int j = i; while(j != f + 1){ swap(s[j], s[j - 1]); j--; ans++; } if(s[f] > 0) { swap(s[f], s[f + 1]); ans++; } d[-s[i]].erase(f); }else{ d[s[i]].insert(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...