結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
kyuna
|
| 提出日時 | 2019-08-24 14:02:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 296 ms / 3,000 ms |
| コード長 | 945 bytes |
| コンパイル時間 | 916 ms |
| コンパイル使用メモリ | 78,620 KB |
| 実行使用メモリ | 5,920 KB |
| 最終ジャッジ日時 | 2024-10-14 12:44:52 |
| 合計ジャッジ時間 | 5,573 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
int main() {
max_heap<long long> small;
min_heap<long long> large;
int q, k; cin >> q >> k;
while (q--) {
int t; cin >> t;
if (t == 1) {
long long v; cin >> v;
if (small.size() < k) {
small.emplace(v);
continue;
}
small.emplace(v);
large.emplace(small.top()); small.pop();
} else {
if (small.size() < k) {
cout << -1 << endl;
continue;
}
cout << small.top() << endl; small.pop();
if (!large.empty()) {
small.emplace(large.top()); large.pop();
}
}
}
return 0;
}
kyuna