結果
| 問題 |
No.1282 Display Elements
|
| コンテスト | |
| ユーザー |
zumin
|
| 提出日時 | 2021-03-24 00:40:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 127 ms / 2,000 ms |
| コード長 | 815 bytes |
| コンパイル時間 | 828 ms |
| コンパイル使用メモリ | 83,912 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2024-11-26 08:23:46 |
| 合計ジャッジ時間 | 2,749 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;
using ll=long long;
ll op(ll a,ll b) {return a+b;}
ll e() {return 0LL;}
int main(){
ll n,ans=0;
cin>>n;
vector<ll> a(n),b(n),sortedb(n);
segtree<ll,op,e> s(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>b[i];
copy(b.begin(),b.end(),sortedb.begin());
sort(a.begin(),a.end());
sort(sortedb.begin(),sortedb.end());
for(int i=0;i<n;i++){
ll ai=a[i],bi=b[i];
ll inda=lower_bound(sortedb.begin(),sortedb.end(),ai)-sortedb.begin();
ll indb=lower_bound(sortedb.begin(),sortedb.end(),bi)-sortedb.begin();
s.set(indb,s.get(indb)+1);
ans+=s.prod(0,inda);
}
cout<<ans<<endl;
return 0;
}
zumin