結果

問題 No.2220 Range Insert & Point Mex
ユーザー otoshigootoshigo
提出日時 2023-02-18 14:57:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 1,265 bytes
コンパイル時間 2,429 ms
コンパイル使用メモリ 214,664 KB
実行使用メモリ 14,448 KB
最終ジャッジ日時 2023-09-28 18:20:47
合計ジャッジ時間 7,324 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 111 ms
13,808 KB
testcase_14 AC 110 ms
13,752 KB
testcase_15 AC 110 ms
13,652 KB
testcase_16 AC 110 ms
13,264 KB
testcase_17 AC 111 ms
12,560 KB
testcase_18 AC 109 ms
13,712 KB
testcase_19 AC 110 ms
13,652 KB
testcase_20 AC 114 ms
12,632 KB
testcase_21 AC 113 ms
12,788 KB
testcase_22 AC 114 ms
12,964 KB
testcase_23 AC 133 ms
13,352 KB
testcase_24 AC 109 ms
11,720 KB
testcase_25 AC 85 ms
8,740 KB
testcase_26 AC 117 ms
13,672 KB
testcase_27 AC 97 ms
10,732 KB
testcase_28 AC 20 ms
4,772 KB
testcase_29 AC 24 ms
4,684 KB
testcase_30 AC 23 ms
4,704 KB
testcase_31 AC 89 ms
13,028 KB
testcase_32 AC 77 ms
9,812 KB
testcase_33 AC 77 ms
9,656 KB
testcase_34 AC 123 ms
13,040 KB
testcase_35 AC 122 ms
14,208 KB
testcase_36 AC 122 ms
12,752 KB
testcase_37 AC 119 ms
13,532 KB
testcase_38 AC 121 ms
14,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<tuple<int,int,int>>T;
    vector<int>A(n);
    rep(i,n){
        int l,r;
        cin>>l>>r>>A[i];
        T.push_back(make_tuple(l,-1,i));
        T.push_back(make_tuple(r,1,i));
    }
    int q;
    cin>>q;
    rep(i,q){
        int x;
        cin>>x;
        T.push_back(make_tuple(x,0,i));
    }
    sort(all(T));
    set<int>se;
    rep(i,n+1)se.insert(i);
    vector<int>C(n+1),ans(q);
    for(auto[x,t,i]:T){
        if(t==0){
            ans[i]=*se.begin();
        }else{
            if(A[i]>n)continue;
            if(t==-1){
                if(C[A[i]]==0)se.erase(A[i]);
                C[A[i]]++;
            }else{
                C[A[i]]--;
                if(C[A[i]]==0)se.insert(A[i]);
            }
        }
    }
    rep(i,q)cout<<ans[i]<<"\n";
}
0