結果

問題 No.649 ここでちょっとQK!
ユーザー ei1333333ei1333333
提出日時 2018-02-09 22:36:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 3,000 ms
コード長 679 bytes
コンパイル時間 2,768 ms
コンパイル使用メモリ 226,388 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-04-17 05:04:00
合計ジャッジ時間 6,266 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 23 ms
5,376 KB
testcase_04 AC 164 ms
16,384 KB
testcase_05 AC 160 ms
16,384 KB
testcase_06 AC 170 ms
16,256 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 67 ms
8,704 KB
testcase_13 AC 65 ms
8,704 KB
testcase_14 AC 63 ms
8,704 KB
testcase_15 AC 67 ms
8,832 KB
testcase_16 AC 68 ms
9,344 KB
testcase_17 AC 76 ms
9,600 KB
testcase_18 AC 87 ms
10,112 KB
testcase_19 AC 93 ms
10,496 KB
testcase_20 AC 104 ms
11,264 KB
testcase_21 AC 117 ms
11,520 KB
testcase_22 AC 121 ms
12,032 KB
testcase_23 AC 125 ms
12,544 KB
testcase_24 AC 140 ms
13,056 KB
testcase_25 AC 152 ms
13,440 KB
testcase_26 AC 161 ms
13,952 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 60 ms
8,704 KB
testcase_31 AC 60 ms
9,216 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 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;

using int64 = long long;

tree< pair< int64, int >, null_type, less< pair< int64, int > >, rb_tree_tag, tree_order_statistics_node_update > ts;

int main()
{
  int Q, K;
  scanf("%d %d", &Q, &K);
  --K;
  int ptr = 0;
  while(Q--) {
    int t;
    scanf("%d", &t);
    if(t == 1) {
      int64 x;
      scanf("%lld", &x);
      ts.insert(make_pair(x, ptr++));
    } else {
      if((int) ts.size() - 1 >= K) {
        auto p = ts.find_by_order(K);
        printf("%lld\n", p->first);
        ts.erase(p);
      } else {
        puts("-1");
      }
    }
  }

}

0