結果

問題 No.610 区間賞(Section Award)
ユーザー finefine
提出日時 2017-12-10 18:35:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 175,920 KB
実行使用メモリ 8,812 KB
最終ジャッジ日時 2023-08-20 09:56:06
合計ジャッジ時間 6,607 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 16 ms
4,456 KB
testcase_20 AC 107 ms
8,056 KB
testcase_21 AC 11 ms
4,380 KB
testcase_22 AC 61 ms
6,448 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 19 ms
4,624 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 39 ms
5,500 KB
testcase_27 AC 94 ms
8,068 KB
testcase_28 AC 81 ms
7,580 KB
testcase_29 AC 55 ms
6,260 KB
testcase_30 AC 76 ms
7,216 KB
testcase_31 AC 35 ms
5,364 KB
testcase_32 AC 90 ms
7,632 KB
testcase_33 AC 10 ms
4,380 KB
testcase_34 AC 104 ms
8,060 KB
testcase_35 AC 41 ms
5,540 KB
testcase_36 AC 92 ms
7,792 KB
testcase_37 AC 78 ms
7,076 KB
testcase_38 AC 18 ms
4,476 KB
testcase_39 AC 105 ms
8,092 KB
testcase_40 AC 100 ms
8,140 KB
testcase_41 AC 104 ms
8,132 KB
testcase_42 AC 103 ms
8,072 KB
testcase_43 AC 102 ms
8,088 KB
testcase_44 AC 186 ms
7,776 KB
testcase_45 AC 230 ms
8,812 KB
testcase_46 AC 232 ms
8,704 KB
testcase_47 AC 80 ms
7,492 KB
testcase_48 AC 73 ms
7,036 KB
testcase_49 AC 83 ms
7,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

//1-indexであることに注意
struct BIT {
    int n;
    vector<int> data;

    BIT(int n) : n(n), data(n + 1, 0) {}

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> memo;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        memo[x] = i;
    }
    BIT b(n);
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (i == b.sum(memo[x])) ans.push_back(x);
        b.add(memo[x], 1);
    }
    sort(ans.begin(), ans.end());
    for (int x : ans) {
        cout << x << endl;
    }
    return 0;
}
0