結果
| 問題 | No.3298 K-th Slime |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-10 23:13:46 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 94 ms / 2,000 ms |
| + 465µs | |
| コード長 | 737 bytes |
| 記録 | |
| コンパイル時間 | 1,185 ms |
| コンパイル使用メモリ | 216,356 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-15 16:16:33 |
| 合計ジャッジ時間 | 3,536 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
}
}