結果
問題 |
No.3298 K-th Slime
|
ユーザー |
|
提出日時 | 2025-10-06 00:12:44 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 849 bytes |
コンパイル時間 | 3,180 ms |
コンパイル使用メモリ | 281,996 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-10-06 00:12:51 |
合計ジャッジ時間 | 5,391 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 RE * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, K, Q; cin >> N >> K >> Q; priority_queue<ll> small; priority_queue<ll, vector<ll>, greater<ll>> large; rep(i, 0, N) { ll A; cin >> A; small.push(A); if (small.size() > K) { large.push(small.top()); small.pop(); } } rep(query, 0, Q) { int t; cin >> t; if (t == 1) { ll x; cin >> x; small.push(x); large.push(small.top()); small.pop(); } else if (t == 2) { ll y; cin >> y; y += small.top(); small.pop(); small.push(large.top()); large.pop(); small.push(y); large.push(small.top()); small.pop(); } else { cout << small.top() << '\n'; } } }