結果

問題 No.2220 Range Insert & Point Mex
ユーザー roarisroaris
提出日時 2023-02-18 02:20:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 943 bytes
コンパイル時間 2,506 ms
コンパイル使用メモリ 221,632 KB
実行使用メモリ 35,380 KB
最終ジャッジ日時 2023-09-28 18:19:08
合計ジャッジ時間 12,991 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 318 ms
25,796 KB
testcase_14 AC 318 ms
25,792 KB
testcase_15 AC 320 ms
24,824 KB
testcase_16 AC 317 ms
25,312 KB
testcase_17 AC 317 ms
24,828 KB
testcase_18 AC 318 ms
24,540 KB
testcase_19 AC 314 ms
24,888 KB
testcase_20 AC 551 ms
34,356 KB
testcase_21 AC 557 ms
34,744 KB
testcase_22 AC 554 ms
35,380 KB
testcase_23 AC 384 ms
29,272 KB
testcase_24 AC 249 ms
26,280 KB
testcase_25 AC 267 ms
19,116 KB
testcase_26 AC 324 ms
29,364 KB
testcase_27 AC 174 ms
23,960 KB
testcase_28 AC 150 ms
8,940 KB
testcase_29 AC 153 ms
8,940 KB
testcase_30 AC 153 ms
8,904 KB
testcase_31 AC 254 ms
25,764 KB
testcase_32 AC 216 ms
19,188 KB
testcase_33 AC 221 ms
19,068 KB
testcase_34 AC 349 ms
27,712 KB
testcase_35 AC 361 ms
28,640 KB
testcase_36 AC 326 ms
29,040 KB
testcase_37 AC 337 ms
28,232 KB
testcase_38 AC 318 ms
27,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
typedef long long ll;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<vector<int>> event;
    rep(i, N) {
        int l, r, a; cin >> l >> r >> a;
        event.pb({l, 0, a});
        event.pb({r+1, 1, a});
    }
    int Q; cin >> Q;
    rep(i, Q) {
        int x; cin >> x;
        event.pb({x, 2, i});
    }
    sort(event.begin(), event.end());
    
    int ans[Q];
    set<int> s;
    rep(i, N+1) s.insert(i);
    map<int, int> mp;
    
    rep(i, event.size()) {
        if (event[i][1]==0) {
            mp[event[i][2]]++;
            s.erase(event[i][2]);
        } else if (event[i][1]==1) {
            mp[event[i][2]]--;
            if (mp[event[i][2]]==0) s.insert(event[i][2]);
        } else ans[event[i][2]] = *s.begin();
    }
    
    rep(i, Q) cout << ans[i] << endl;
}
0