제출 #266435

#제출 시각아이디문제언어결과실행 시간메모리
266435wdjpngArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms256 KiB
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) #define lint long long using namespace std; lint count_swaps(vector<int> s){ int n = s.size(); vector<set<int>>set(2*n+1); vector<bool>ignore(n); rep(i,n){ set[s[i]+n].insert(i); } int sum=0; rep(i,n){ if(ignore[i]){continue;} int nearest=*set[-s[i]+n].begin(); set[-s[i]+n].erase(set[-s[i]+n].begin()); ignore[nearest]=true; if(s[i]>0){sum++;} sum+=nearest-i-1; } return sum; }
#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...