結果

問題 No.1115 二つの数列 / Two Sequences
ユーザー hiro71687khiro71687k
提出日時 2023-06-04 01:38:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 4,580 ms
コンパイル使用メモリ 260,264 KB
実行使用メモリ 8,476 KB
最終ジャッジ日時 2023-08-28 08:06:35
合計ジャッジ時間 8,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 60 ms
7,908 KB
testcase_04 AC 68 ms
8,076 KB
testcase_05 AC 59 ms
7,832 KB
testcase_06 AC 54 ms
7,680 KB
testcase_07 AC 68 ms
8,068 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 37 ms
6,096 KB
testcase_10 AC 65 ms
8,476 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 71 ms
8,352 KB
testcase_13 AC 70 ms
8,356 KB
testcase_14 AC 70 ms
8,404 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 24 ms
5,128 KB
testcase_25 AC 52 ms
7,256 KB
testcase_26 AC 13 ms
4,380 KB
testcase_27 AC 31 ms
5,408 KB
testcase_28 AC 41 ms
5,932 KB
testcase_29 AC 56 ms
7,520 KB
testcase_30 AC 66 ms
8,044 KB
testcase_31 AC 17 ms
4,396 KB
testcase_32 AC 12 ms
4,376 KB
testcase_33 AC 59 ms
8,080 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,384 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=2000000000000000000;
ll mod=998244353;
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);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
        b[i]--;
    }
    vector<ll>bb(n);
    for (ll i = 0; i < n; i++)
    {
        bb[b[i]]=i;
    }
    for (ll i = 0; i < n; i++)
    {
        a[i]=bb[a[i]];
        b[i]=i;
    }
    vector<ll>c(n,0);
    segtree<ll,op,e>seg(c);
    ll ans=0;
    for (ll i = 0; i < n; i++)
    {
        ans+=seg.prod(a[i],n);
        seg.set(a[i],1);
    }
    cout << ans << endl;
}
0