結果
| 問題 | No.3298 K-th Slime | 
| コンテスト | |
| ユーザー |  tau1235 | 
| 提出日時 | 2025-10-05 15:22:49 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 155 ms / 2,000 ms | 
| コード長 | 975 bytes | 
| コンパイル時間 | 2,927 ms | 
| コンパイル使用メモリ | 287,332 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-05 15:23:12 | 
| 合計ジャッジ時間 | 5,457 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 25 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
  using ll=long long;
  int n,k,q;
  cin>>n>>k>>q;
  priority_queue<ll> pq,pq2;
  vector<ll> a(n);
  for (int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  for (int i=0;i<k;i++) pq.push(a[i]);
  for (int i=k;i<n;i++) pq2.push(-a[i]);
  pq2.push(-1e18);
  while (q--){
    int t;
    cin>>t;
    if (t==1){
      ll x;
      cin>>x;
      pq2.push(-x);
      while (pq.top()>-pq2.top()){
        ll top=pq.top();
        ll top2=pq2.top();
        pq.pop();
        pq2.pop();
        pq2.push(-top);
        pq.push(-top2);
      }
    }
    if (t==2){
      ll y;
      cin>>y;
      ll top=pq.top();
      pq.pop();
      pq.push(top+y);
      while (pq.top()>-pq2.top()){
        ll top=pq.top();
        ll top2=pq2.top();
        pq.pop();
        pq2.pop();
        pq2.push(-top);
        pq.push(-top2);
      }
      //cout<<pq.top()<<endl;
    }
    if (t==3){
      cout<<pq.top()<<endl;
    }
  }
}
            
            
            
        