이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef int64_t lld;
typedef pair<int, int> pii;
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<typename T>
using OST = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
map<int, int> cnt;
bool operator<(pii a, pii b){
if(abs(a.ff) != abs(b.ff))return abs(a.ff) < abs(b.ff);
if(a.ss != b.ss)return a.ss < b.ss;
return a.ff < b.ff;
}
OST<pii> ost;
long long count_swaps(vector<int> s) {
lld ans = 0;
for(auto i: s)ans += ost.size()-ost.order_of_key({i, cnt[i]}), ost.insert({i, cnt[i]++});
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |