結果

問題 No.649 ここでちょっとQK!
ユーザー ninoinuininoinui
提出日時 2020-07-19 03:08:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 193 ms / 3,000 ms
コード長 642 bytes
コンパイル時間 4,416 ms
コンパイル使用メモリ 232,768 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-05-08 22:05:57
合計ジャッジ時間 9,103 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 27 ms
5,248 KB
testcase_04 AC 171 ms
15,872 KB
testcase_05 AC 169 ms
15,872 KB
testcase_06 AC 174 ms
15,872 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 72 ms
8,320 KB
testcase_13 AC 72 ms
8,320 KB
testcase_14 AC 72 ms
8,320 KB
testcase_15 AC 79 ms
8,448 KB
testcase_16 AC 78 ms
8,960 KB
testcase_17 AC 88 ms
9,216 KB
testcase_18 AC 97 ms
9,728 KB
testcase_19 AC 107 ms
10,240 KB
testcase_20 AC 117 ms
10,752 KB
testcase_21 AC 124 ms
11,264 KB
testcase_22 AC 134 ms
11,904 KB
testcase_23 AC 155 ms
12,416 KB
testcase_24 AC 161 ms
12,800 KB
testcase_25 AC 175 ms
13,440 KB
testcase_26 AC 193 ms
13,824 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 62 ms
8,320 KB
testcase_31 AC 72 ms
8,704 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  tree<pair<long, int>, null_type, less<pair<long, int>>, rb_tree_tag, tree_order_statistics_node_update> T;
  int Q, K;
  cin >> Q >> K;
  int id = 0;
  while (Q--) {
    int q;
    cin >> q;
    if (q == 1) {
      long v;
      cin >> v;
      T.insert({v, id++});
    } else {
      if (T.size() < K) {
        cout << -1 << "\n";
        continue;
      }
      auto a = T.find_by_order(K - 1);
      cout << a -> first << "\n";
      T.erase(a);
    }
  }
}
0