結果
問題 | No.649 ここでちょっとQK! |
ユーザー |
|
提出日時 | 2019-05-20 19:33:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 3,000 ms |
コード長 | 955 bytes |
コンパイル時間 | 1,406 ms |
コンパイル使用メモリ | 173,884 KB |
実行使用メモリ | 5,944 KB |
最終ジャッジ日時 | 2024-09-17 06:41:59 |
合計ジャッジ時間 | 3,915 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include<bits/stdc++.h>using namespace std;int main(){cin.tie(0);ios::sync_with_stdio(false);int Q, K;cin >> Q >> K;priority_queue<long long, vector<long long>, less<long long>> Ls;priority_queue<long long, vector<long long>, greater<long long>> Rs;int q;long long v;while (Q--){cin >> q;if (q == 1){cin >> v;if (Ls.size() < K){Ls.push(v);}else if (Ls.top() <= v){Rs.push(v);}else{Rs.push(Ls.top());Ls.pop();Ls.push(v);}}else{if (Ls.size() < K){cout << -1 << '\n';}else{cout << Ls.top() << '\n';Ls.pop();if (Rs.empty()) continue;Ls.push(Rs.top());Rs.pop();}}}return 0;}