結果

問題 No.1922 Separate and Attach
ユーザー りあん
提出日時 2022-05-03 23:47:45
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 3,653 ms
コンパイル使用メモリ 256,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 22:27:40
合計ジャッジ時間 6,881 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

using P = pair<int, int>;
const int M = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n), mp(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }
    for (int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        --b;
        mp[b] = i;
    }
    vector<int> idx(n);
    for (int i = 0; i < n; ++i) {
        a[i] = mp[a[i]];
        idx[a[i]] = i;
    }
    int c = 0;
    for (int i = 0; i + 1 < n; ++i) {
        if (idx[i] > idx[i + 1]) ++c;
    }
    int ans = 0;
    while (c >> ans) ++ans;
    cout << ans << '\n';

    return 0;
}
0