結果

問題 No.649 ここでちょっとQK!
ユーザー CaiiiiiiiiCaiiiiiiii
提出日時 2024-05-28 00:18:21
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 561 bytes
コンパイル時間 2,544 ms
コンパイル使用メモリ 202,988 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-12-20 20:37:17
合計ジャッジ時間 8,121 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 12 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#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<int> big, small;

int main() {

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

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

}
0