結果

問題 No.649 ここでちょっとQK!
コンテスト
ユーザー Caiiiiiiii
提出日時 2024-05-28 00:19:12
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 96 ms / 3,000 ms
コード長 565 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,148 ms
コンパイル使用メモリ 182,988 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2026-05-27 17:02:19
合計ジャッジ時間 7,044 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

typedef long long LL;

const int N = 1e5 + 7;
const int MOD = 998244353;

int n, m, a[N], ans;
std::multiset<LL> big, small;

int main() {

  scanf("%d%d", &n, &m);

  while(n--) {
    LL t, x;
    scanf("%lld", &t);
    if(t == 1) {
      scanf("%lld", &x);
      small.insert(x);
      if(small.size() >= m) {
	big.insert(*small.rbegin());
	small.erase(--small.end());
      }
    }
    else {
      if(!big.empty()) {
	printf("%lld\n", *big.begin());
	big.erase(big.begin());
      }
      else
	puts("-1");
    }
  }
  
  return 0;

}
0