結果

問題 No.1282 Display Elements
ユーザー hiro71687khiro71687k
提出日時 2023-03-24 03:22:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 274,604 KB
実行使用メモリ 24,648 KB
最終ジャッジ日時 2023-10-18 19:51:51
合計ジャッジ時間 7,574 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 258 ms
23,204 KB
testcase_16 AC 93 ms
11,868 KB
testcase_17 AC 211 ms
20,576 KB
testcase_18 AC 126 ms
13,612 KB
testcase_19 AC 96 ms
7,044 KB
testcase_20 AC 91 ms
7,044 KB
testcase_21 AC 281 ms
24,648 KB
testcase_22 AC 105 ms
7,044 KB
testcase_23 AC 286 ms
24,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0