結果

問題 No.2220 Range Insert & Point Mex
ユーザー stoqstoq
提出日時 2023-01-30 08:33:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 913 bytes
コンパイル時間 2,224 ms
コンパイル使用メモリ 216,248 KB
実行使用メモリ 13,688 KB
最終ジャッジ日時 2023-09-14 15:46:44
合計ジャッジ時間 12,188 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,356 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 1 ms
4,356 KB
testcase_07 AC 2 ms
4,356 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 AC 1 ms
4,356 KB
testcase_10 AC 2 ms
4,356 KB
testcase_11 AC 2 ms
4,356 KB
testcase_12 AC 2 ms
4,356 KB
testcase_13 AC 194 ms
13,116 KB
testcase_14 AC 191 ms
12,564 KB
testcase_15 AC 193 ms
12,064 KB
testcase_16 AC 193 ms
12,264 KB
testcase_17 AC 192 ms
12,492 KB
testcase_18 AC 198 ms
12,848 KB
testcase_19 AC 197 ms
12,456 KB
testcase_20 AC 215 ms
12,808 KB
testcase_21 AC 214 ms
12,204 KB
testcase_22 AC 215 ms
13,536 KB
testcase_23 AC 216 ms
13,688 KB
testcase_24 WA -
testcase_25 AC 154 ms
10,856 KB
testcase_26 AC 189 ms
12,360 KB
testcase_27 WA -
testcase_28 AC 66 ms
9,756 KB
testcase_29 AC 76 ms
9,752 KB
testcase_30 AC 77 ms
9,504 KB
testcase_31 AC 158 ms
12,780 KB
testcase_32 AC 136 ms
11,064 KB
testcase_33 AC 139 ms
11,228 KB
testcase_34 AC 190 ms
13,368 KB
testcase_35 AC 191 ms
13,292 KB
testcase_36 AC 187 ms
13,584 KB
testcase_37 AC 187 ms
13,096 KB
testcase_38 AC 189 ms
12,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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