結果
| 問題 | No.3298 K-th Slime |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-10 23:13:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 173 ms / 2,000 ms |
| コード長 | 737 bytes |
| 記録 | |
| コンパイル時間 | 1,913 ms |
| コンパイル使用メモリ | 200,928 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-10 23:13:51 |
| 合計ジャッジ時間 | 5,241 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
int N, K, Q;
cin >> N >>K >> Q;
priority_queue<ll> pque1;
priority_queue<ll, std::vector<ll>, greater<ll>> pque2;
auto add = [&](ll x) -> void {
pque1.push(x);
if (pque1.size() > K) {
pque2.push(pque1.top());
pque1.pop();
}
};
auto ers = [&]() -> ll {
ll ret = pque1.top();
pque1.pop();
if (!pque2.empty()) {
pque1.push(pque2.top());
pque2.pop();
}
return ret;
};
while (N--) {
ll a;
cin >> a;
add(a);
}
while (Q--) {
int t;
cin >> t;
if (t == 1) {
ll x;
cin >> x;
add(x);
} else if (t == 2) {
ll y;
cin >> y;
y += ers();
add(y);
} else {
cout << pque1.top() << endl;
}
}
}