結果
| 問題 | No.3469 ジャッジ結果の逆転数 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-06 21:54:12 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 414 ms / 2,000 ms |
| コード長 | 717 bytes |
| 記録 | |
| コンパイル時間 | 3,141 ms |
| コンパイル使用メモリ | 349,208 KB |
| 実行使用メモリ | 26,880 KB |
| 最終ジャッジ日時 | 2026-03-06 21:54:20 |
| 合計ジャッジ時間 | 7,053 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <atcoder/fenwicktree>
struct dcin{template<typename T>dcin&operator>>(T&x){return std::cin>>x,x--,*this;}}dcin;
ll inversion_num(vector<ll> a){
ll n = a.size(), res = 0;
atcoder::fenwick_tree<ll> fw(n);
for(ll i = n-1; i >= 0;i--){
res += fw.sum(0,a[i]);
fw.add(a[i],1);
}
return res;
}
map<ll,ll> compress(auto &a){
set<ll> s(a.begin(),a.end());
map<ll,ll> mp;
ll cnt = 0;
for(ll i : s)mp[i] = cnt++;
for(ll &i : a)i = mp[i];
return mp;
}
int main(){
ll n; cin >> n;
vector<ll> a(n);
for(ll &i : a)dcin >> i;
compress(a);
cout << inversion_num(a) << endl;
}