結果

問題 No.2220 Range Insert & Point Mex
ユーザー stoqstoq
提出日時 2023-01-30 06:40:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 3,648 ms
コンパイル使用メモリ 214,484 KB
実行使用メモリ 13,692 KB
最終ジャッジ日時 2023-09-28 17:56:48
合計ジャッジ時間 12,519 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,376 KB
testcase_04 AC 1 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,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 209 ms
12,728 KB
testcase_14 AC 209 ms
12,608 KB
testcase_15 AC 209 ms
13,656 KB
testcase_16 AC 211 ms
13,448 KB
testcase_17 AC 210 ms
13,304 KB
testcase_18 AC 210 ms
12,344 KB
testcase_19 AC 210 ms
12,664 KB
testcase_20 AC 230 ms
12,832 KB
testcase_21 AC 232 ms
13,628 KB
testcase_22 AC 229 ms
12,416 KB
testcase_23 AC 231 ms
13,328 KB
testcase_24 AC 191 ms
11,136 KB
testcase_25 AC 149 ms
8,228 KB
testcase_26 AC 202 ms
13,332 KB
testcase_27 AC 162 ms
10,980 KB
testcase_28 AC 41 ms
4,760 KB
testcase_29 AC 54 ms
4,792 KB
testcase_30 AC 53 ms
4,776 KB
testcase_31 AC 176 ms
13,692 KB
testcase_32 AC 131 ms
9,484 KB
testcase_33 AC 135 ms
9,420 KB
testcase_34 AC 204 ms
13,324 KB
testcase_35 AC 206 ms
12,952 KB
testcase_36 AC 202 ms
12,536 KB
testcase_37 AC 202 ms
12,820 KB
testcase_38 AC 204 ms
12,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int n;
  cin >> n;
  vector<array<int, 3>> event;
  for (int i = 0; i < n; i++) {
    int l, r, a;
    cin >> l >> r >> a;
    event.push_back({l, 1, a});
    event.push_back({r, 3, a});
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    event.push_back({x, 2, i});
  }
  sort(begin(event), end(event));

  set<int> unused;
  for (int i = 0; i <= n; i++) unused.insert(i);
  vector<int> cnt(n), ans(q);
  for (auto [x, type, num] : event) {
    if (type == 1) {  // 追加
      if (num >= n) continue;
      if (cnt[num] == 0) unused.erase(num);
      cnt[num]++;
    } else if (type == 2) {  // クエリ
      ans[num] = *unused.begin();
    } else {  // 削除
      if (num >= n) continue;
      cnt[num]--;
      if (cnt[num] == 0) unused.insert(num);
    }
  }
  for (auto a : ans) cout << a << "\n";
}
0