結果
| 問題 |
No.3298 K-th Slime
|
| コンテスト | |
| ユーザー |
tetra4
|
| 提出日時 | 2025-10-05 14:26:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 1,132 bytes |
| コンパイル時間 | 3,225 ms |
| コンパイル使用メモリ | 287,116 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-10-05 14:26:47 |
| 合計ジャッジ時間 | 4,566 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll N, K, Q;
vector<ll> A;
void input() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> K >> Q;
A.resize(N);
for (ll i=0; i<N; ++i) cin >> A[i];
}
void solve() {
priority_queue<ll> small;
priority_queue<ll, vector<ll>, greater<ll>> large;
sort(A.begin(), A.end());
for (ll i=0; i<K; ++i) small.push(A[i]);
for (ll i=K; i<N; ++i) large.push(A[i]);
while (Q--) {
ll kth = small.top();
ll q;
cin >> q;
if (q == 1) {
ll x;
cin >> x;
if (x < kth) {
small.pop();
small.push(x);
large.push(kth);
} else {
large.push(x);
}
} else if (q == 2) {
ll y;
cin >> y;
small.pop();
large.push(kth + y);
kth = large.top();
large.pop();
small.push(kth);
} else {
cout << kth << "\n";
}
}
}
int main() {
input();
solve();
return 0;
}
tetra4