제출 #294880

#제출 시각아이디문제언어결과실행 시간메모리
294880theStaticMindArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms256 KiB
#include <bits/stdc++.h> #include "shoes.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; long long count_swaps(std::vector<int> s) { int n = s.size(); ordered_set S; set<int> W[n + 1]; for(int i = 0; i < n; i++){ if(s[i] > 0) S.insert(i), W[s[i]].insert(i); } long long cnt = 0; for(int i = 0; i < n; i++){ if(s[i] > 0) continue; cnt += S.order_of_key(i); cnt += S.order_of_key(*W[-s[i]].begin()); S.erase(*W[-s[i]].begin()); W[-s[i]].erase(W[-s[i]].begin()); } return cnt; }
#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...