結果
問題 | No.1282 Display Elements |
ユーザー |
![]() |
提出日時 | 2023-03-24 03:22:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 274 ms / 2,000 ms |
コード長 | 950 bytes |
コンパイル時間 | 3,728 ms |
コンパイル使用メモリ | 260,776 KB |
最終ジャッジ日時 | 2025-02-11 16:40:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=144499999994; ll mod=1000000007; ll op(ll a,ll b){ return a+b; } ll e(){ return 0; } int main(){ ll n; cin >> n; vector<ll>a(n),b(n); vector<ll>c; for (ll i = 0; i < n; i++) { cin >> a[i]; c.push_back(a[i]); } sort(a.begin(),a.end()); for (ll i = 0; i < n; i++) { cin >> b[i]; c.push_back(b[i]); } sort(c.begin(),c.end()); c.erase(unique(c.begin(), c.end()), c.end()); map<ll,ll>memo; for (ll i = 0; i < c.size(); i++) { memo[c[i]]=i; } vector<ll>x(c.size(),0); segtree<ll,op,e>seg(x); ll ans=0; for (ll i = 0; i < n; i++) { seg.set(memo[b[i]],seg.get(memo[b[i]])+1); ans+=seg.prod(0,memo[a[i]]); } cout << ans << endl; }