結果

問題 No.2220 Range Insert & Point Mex
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-02-19 02:20:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 301 ms / 2,000 ms
コード長 1,113 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 171,596 KB
実行使用メモリ 5,740 KB
最終ジャッジ日時 2023-09-28 18:21:52
合計ジャッジ時間 10,562 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 296 ms
4,832 KB
testcase_14 AC 293 ms
4,936 KB
testcase_15 AC 295 ms
4,776 KB
testcase_16 AC 301 ms
4,840 KB
testcase_17 AC 297 ms
4,836 KB
testcase_18 AC 291 ms
4,836 KB
testcase_19 AC 296 ms
4,988 KB
testcase_20 AC 283 ms
4,380 KB
testcase_21 AC 282 ms
4,376 KB
testcase_22 AC 283 ms
4,376 KB
testcase_23 AC 272 ms
5,652 KB
testcase_24 AC 186 ms
5,684 KB
testcase_25 AC 227 ms
4,496 KB
testcase_26 AC 261 ms
5,740 KB
testcase_27 AC 92 ms
5,568 KB
testcase_28 AC 167 ms
4,380 KB
testcase_29 AC 175 ms
4,380 KB
testcase_30 AC 179 ms
4,376 KB
testcase_31 AC 255 ms
4,836 KB
testcase_32 AC 223 ms
4,428 KB
testcase_33 AC 227 ms
4,460 KB
testcase_34 AC 265 ms
4,676 KB
testcase_35 AC 270 ms
4,580 KB
testcase_36 AC 260 ms
4,684 KB
testcase_37 AC 262 ms
4,684 KB
testcase_38 AC 259 ms
5,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
const int N = 1 << 17;

int tr[N * 2];

vector<pii> add, del;

inline void mod(int p, int x) {
    tr[N + p] += x;
    for(int i = (N + p) / 2; i; i /= 2)
        tr[i] = min(tr[i * 2], tr[i * 2 + 1]);
}

inline int query() {
    int ret = 1;
    while(ret < N) {
        ret *= 2;
        if(tr[ret] > 0) ret ++;
    }
    return ret - N;
}

int main() {
    int n;
    cin >> n;
    for(int i = 1, l, r, a; i <= n; i ++) {
        cin >> l >> r >> a;
        if(a >= N) continue;
        add.push_back({l, a});
        del.push_back({r + 1, a});
    }

    sort(add.begin(), add.end(), greater<pii>());
    sort(del.begin(), del.end(), greater<pii>());

    int q;
    cin >> q;
    for(int i = 1, x; i <= q; i ++) {
        cin >> x;
        while(add.size() && add.back().first <= x) {
            mod(add.back().second, 1);
            add.pop_back();
        }
        while(del.size() && del.back().first <= x) {
            mod(del.back().second, -1);
            del.pop_back();
        }
        cout << query() << "\n";
    }
}
0