結果

問題 No.3298 K-th Slime
ユーザー MM
提出日時 2025-10-05 16:50:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,477 bytes
コンパイル時間 4,279 ms
コンパイル使用メモリ 258,136 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-05 16:50:21
合計ジャッジ時間 7,207 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec vector
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back 
#define eb emplace_back

using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
const ll mod = 998244353;
using mint = modint998244353;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};
// using Graph = vector<vector<pair<int,ll>>>;
using Graph = vector<vector<int>>;

int main(){
  // input
  int N,K,Q;
  cin >> N >> K >> Q;
  priority_queue<ll> pq;
  priority_queue<ll,vector<ll>,greater<ll>> qq;
  vector<ll> A(N);
  rep(i,N)
    cin >> A[i];
  sort(all(A));
  rep(i,N){
    if(i < K) pq.push(A[i]);
    else qq.push(A[i]);
  }
  
  assert(pq.size() == K);
  assert(qq.size() == N-K);
  // solve
  while(Q--){
    int q;
    cin >> q;
    if(q == 3)
      cout << pq.top() << "\n";
    else if(q == 1){
      ll x;
      cin >> x;
      if(x >= pq.top())
        qq.push(x);
      else{
        pq.push(x);
        qq.push(pq.top());
        pq.pop();
      }
    }
    else if(q == 2){
      ll y;
      cin >> y;
      y += pq.top();
      pq.pop();

      if(y <= qq.top())
        pq.push(y);
      else{
        qq.push(y);
        pq.push(qq.top());
        qq.pop();
      }
    }

    assert(pq.top() <= qq.top());
  }
  
  // output
  
}
0