結果

問題 No.649 ここでちょっとQK!
ユーザー ei1333333ei1333333
提出日時 2018-02-09 22:36:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 673 bytes
コンパイル時間 2,415 ms
コンパイル使用メモリ 224,780 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-17 05:02:47
合計ジャッジ時間 6,334 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 163 ms
16,128 KB
testcase_05 AC 169 ms
16,256 KB
testcase_06 AC 175 ms
16,256 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 68 ms
8,704 KB
testcase_13 AC 65 ms
8,576 KB
testcase_14 AC 66 ms
8,704 KB
testcase_15 AC 68 ms
8,832 KB
testcase_16 AC 67 ms
9,344 KB
testcase_17 AC 79 ms
9,600 KB
testcase_18 AC 88 ms
10,112 KB
testcase_19 AC 96 ms
10,624 KB
testcase_20 AC 106 ms
11,136 KB
testcase_21 WA -
testcase_22 AC 121 ms
12,160 KB
testcase_23 AC 126 ms
12,672 KB
testcase_24 WA -
testcase_25 AC 150 ms
13,440 KB
testcase_26 AC 167 ms
14,208 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 61 ms
8,576 KB
testcase_31 AC 62 ms
9,088 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

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(ts.size() - 1 >= K) {
        auto p = ts.find_by_order(K);
        printf("%lld\n", p->first);
        ts.erase(p);
      } else {
        puts("-1");
      }
    }
  }

}

0