結果
問題 | No.649 ここでちょっとQK! |
ユーザー | Caiiiiiiii |
提出日時 | 2024-05-28 00:19:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 158 ms / 3,000 ms |
コード長 | 565 bytes |
コンパイル時間 | 2,018 ms |
コンパイル使用メモリ | 168,912 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2024-12-20 20:37:24 |
合計ジャッジ時間 | 6,054 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#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; }