結果

問題 No.649 ここでちょっとQK!
ユーザー 0w10w1
提出日時 2018-04-15 03:05:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 279 ms / 3,000 ms
コード長 776 bytes
コンパイル時間 2,065 ms
コンパイル使用メモリ 203,712 KB
実行使用メモリ 5,804 KB
最終ジャッジ日時 2023-09-09 05:35:35
合計ジャッジ時間 7,519 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 279 ms
4,376 KB
testcase_04 AC 66 ms
5,584 KB
testcase_05 AC 54 ms
5,804 KB
testcase_06 AC 54 ms
5,352 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 43 ms
4,376 KB
testcase_13 AC 43 ms
4,380 KB
testcase_14 AC 42 ms
4,376 KB
testcase_15 AC 45 ms
4,376 KB
testcase_16 AC 43 ms
4,376 KB
testcase_17 AC 50 ms
4,380 KB
testcase_18 AC 56 ms
4,380 KB
testcase_19 AC 61 ms
4,376 KB
testcase_20 AC 66 ms
4,376 KB
testcase_21 AC 72 ms
4,560 KB
testcase_22 AC 75 ms
4,544 KB
testcase_23 AC 80 ms
4,576 KB
testcase_24 AC 84 ms
4,508 KB
testcase_25 AC 90 ms
4,612 KB
testcase_26 AC 94 ms
4,620 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 35 ms
4,380 KB
testcase_31 AC 38 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  int Q, K;
  cin >> Q >> K;
  priority_queue<int64_t> lpq, gpq;
  for (int qi = 0; qi < Q; ++qi) {
    int OP;
    cin >> OP;
    if (OP == 1) {
      int64_t V;
      cin >> V;
      if (lpq.size() < K) {
        lpq.emplace(V);
      } else {
        if (V >= lpq.top()) {
          gpq.emplace(-V);
        } else {
          lpq.emplace(V);
          gpq.emplace(-lpq.top());
          lpq.pop();
        }
      }
    } else {
      if (lpq.size() < K) {
        cout << -1 << endl;
      } else {
        cout << lpq.top() << endl;
        lpq.pop();
        if (gpq.size()) {
          lpq.emplace(-gpq.top());
          gpq.pop();
        }
      }
    }
  }
  return 0;
}
0