結果
問題 |
No.649 ここでちょっとQK!
|
ユーザー |
|
提出日時 | 2020-03-13 15:18:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 819 bytes |
コンパイル時間 | 2,511 ms |
コンパイル使用メモリ | 195,580 KB |
最終ジャッジ日時 | 2025-01-09 06:38:21 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 5 WA * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int Q, K; cin >> Q >> K; multiset<int64_t> bag0; multiset<int64_t> bag1; while (Q--) { int P; cin >> P; if (P == 1) { int64_t V; cin >> V; bag0.insert(V); if (bag1.size() && *bag1.begin() < *--bag0.end()) { bag1.insert(*--bag0.end()); bag0.erase(--bag0.end()); } while (bag0.size() < K && bag1.size()) { bag0.insert(*bag1.begin()); bag1.erase(bag1.begin()); } while (bag0.size() > K) { bag1.insert(*--bag0.end()); bag0.erase(--bag0.end()); } } else { if (bag0.size() == K) { cout << *--bag0.end() << endl; bag0.erase(--bag0.end()); } else { cout << -1 << endl; } } } return 0; }