結果

問題 No.649 ここでちょっとQK!
ユーザー ninoinuininoinui
提出日時 2020-07-19 03:08:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 645 bytes
コンパイル時間 2,371 ms
コンパイル使用メモリ 230,580 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-05-08 22:06:49
合計ジャッジ時間 7,482 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
15,488 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 26 ms
5,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

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>>, splay_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