結果

問題 No.649 ここでちょっとQK!
ユーザー pekempeypekempey
提出日時 2018-02-09 22:32:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 3,000 ms
コード長 992 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 122,576 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-04-17 04:55:04
合計ジャッジ時間 5,625 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 23 ms
5,376 KB
testcase_04 AC 175 ms
16,384 KB
testcase_05 AC 171 ms
16,384 KB
testcase_06 AC 166 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 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 68 ms
8,576 KB
testcase_13 AC 67 ms
8,832 KB
testcase_14 AC 66 ms
8,576 KB
testcase_15 AC 68 ms
8,960 KB
testcase_16 AC 67 ms
9,216 KB
testcase_17 AC 76 ms
9,472 KB
testcase_18 AC 83 ms
10,112 KB
testcase_19 AC 90 ms
10,752 KB
testcase_20 AC 98 ms
11,264 KB
testcase_21 AC 110 ms
11,520 KB
testcase_22 AC 119 ms
12,288 KB
testcase_23 AC 127 ms
12,416 KB
testcase_24 AC 137 ms
13,184 KB
testcase_25 AC 157 ms
13,568 KB
testcase_26 AC 158 ms
14,080 KB
testcase_27 AC 2 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 61 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 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// include <ext/pb_ds/assoc_container.hpp>
// include <ext/pb_ds/tree_policy.hpp>
// find_by_order(int) -> iterator
// order_of_key(int) -> int

using namespace __gnu_pbds;

template<class T> using Set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class TKey, class TVal> using Map = tree<TKey, TVal, std::less<TKey>, rb_tree_tag, tree_order_statistics_node_update>;

using namespace std;

long long input() {
  long long t;
  scanf("%lld", &t);
  return t;
}

int main() {
  int q, K;
  cin >> q >> K;

  Set<pair<long long, int>> st;

  while (q--) {
    if (input() == 1) {
      st.insert({input(), q});
    } else {
      if (st.size() >= K) {
        auto it = st.find_by_order(K - 1);
        printf("%lld\n", it->first);
        st.erase(it);
      } else {
        puts("-1");
      }
    }
  }
}
0