제출 #603119

#제출 시각아이디문제언어결과실행 시간메모리
603119misteg168Arranging Shoes (IOI19_shoes)C++17
0 / 100
0 ms212 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second long long count_swaps(std::vector<int> s) { ll n = s.size(); map<ll, set<ll>> v; for(int i = 0; i < n; i++){ v[-s[i]].insert(i); } vector<bool> pos(n, 0); ll ans = 0, curr = 0; for(int i = 0; i < n; i++){ if(pos[i]){ curr--; continue; } ans += *(v[s[i]].begin())-i-curr-1; if(s[i] < 0) ans++; curr++; pos[i] = 1; pos[ *(v[s[i]].begin()) ] = 1; //~ cerr << i << " " << *(v[s[i]].begin()) << " " << ans << " " << curr << "\n"; v[ s[i] ].erase( v[ s[i] ].begin()); } 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...