結果

問題 No.2220 Range Insert & Point Mex
ユーザー umimelumimel
提出日時 2023-02-18 06:55:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 1,539 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 180,692 KB
実行使用メモリ 13,484 KB
最終ジャッジ日時 2023-09-28 18:20:18
合計ジャッジ時間 7,741 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 142 ms
13,056 KB
testcase_14 AC 142 ms
13,228 KB
testcase_15 AC 142 ms
13,168 KB
testcase_16 AC 141 ms
13,484 KB
testcase_17 AC 142 ms
12,608 KB
testcase_18 AC 143 ms
12,648 KB
testcase_19 AC 142 ms
12,408 KB
testcase_20 AC 139 ms
12,300 KB
testcase_21 AC 142 ms
12,204 KB
testcase_22 AC 142 ms
12,620 KB
testcase_23 AC 149 ms
12,844 KB
testcase_24 AC 132 ms
11,216 KB
testcase_25 AC 85 ms
8,784 KB
testcase_26 AC 142 ms
13,008 KB
testcase_27 AC 112 ms
10,396 KB
testcase_28 AC 30 ms
4,712 KB
testcase_29 AC 32 ms
4,708 KB
testcase_30 AC 32 ms
4,696 KB
testcase_31 AC 118 ms
13,012 KB
testcase_32 AC 96 ms
9,544 KB
testcase_33 AC 98 ms
9,732 KB
testcase_34 AC 150 ms
12,740 KB
testcase_35 AC 153 ms
12,364 KB
testcase_36 AC 155 ms
12,356 KB
testcase_37 AC 155 ms
12,088 KB
testcase_38 AC 138 ms
13,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> PQ;
    for(int i=0; i<n; i++){
        int l, r, a; cin >> l >> r >> a; l--; r--;
        PQ.push({l, 0, a}); PQ.push({r, 2, a});
    }

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int x; cin >> x; x--;
        PQ.push({x, 1, i});
    }

    vector<int> ans(q);
    vector<int> cnt(n, 0);
    set<int> st; for(int i=0; i<n; i++) st.insert(i);
    while(!PQ.empty()){
        int t = get<1>(PQ.top());
        if(t==0){
            int a = get<2>(PQ.top());
            if(a<n){
                st.erase(a);
                cnt[a]++;
            }
        }else if(t==1){
            int idx = get<2>(PQ.top());
            if((int)st.size()==0) ans[idx]=n;
            else ans[idx]=*st.begin();
        }else{
            int a = get<2>(PQ.top());
            if(a<n){
                cnt[a]--;
                if(cnt[a]==0) st.insert(a);
            }
        }

        PQ.pop();
    }

    for(int i=0; i<q; i++) cout << ans[i] << "\n";
}
0