結果
| 問題 | No.3298 K-th Slime | 
| コンテスト | |
| ユーザー |  Nichi10p | 
| 提出日時 | 2025-10-05 14:25:33 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 81 ms / 2,000 ms | 
| コード長 | 1,266 bytes | 
| コンパイル時間 | 3,183 ms | 
| コンパイル使用メモリ | 290,744 KB | 
| 実行使用メモリ | 11,008 KB | 
| 最終ジャッジ日時 | 2025-10-05 14:25:52 | 
| 合計ジャッジ時間 | 5,228 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 25 | 
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define  rep(i,s,t) for (auto i=s; i != t; ++i)
#define rrep(i,s,t) for (auto i=t; i-- != s;)
typedef long long ll;
constexpr auto inf = numeric_limits<ll>::max();
constexpr bool chmin(auto &a, auto const &x) { return a > x ? a = x, true : false; }
constexpr bool chmax(auto &a, auto const &x) { return a < x ? a = x, true : false; }
// constexpr auto ascii_lowercase = "qwertyuiopasdfghjklzxcvbnm"sv;
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, k, q;
  cin >> n >> k >> q;
  vector<ll> A(n);
  rep(i,0,n)
    cin >> A[i];
  std::ranges::sort(A);
  multiset<ll> S(A.begin(), A.begin()+k), L(A.begin()+k, A.end());
  L.insert(inf);
  auto balance = [&]() {
    if (*S.rbegin() <= *L.begin()) return;
    ll const a = *S.rbegin();
    ll const b = *L.begin();
    S.insert(b);
    L.insert(a);
    S.erase(prev(S.end()));
    L.erase(L.begin());
  };
  while (q--) {
    ll t, x, y;
    cin >> t;
    switch (t) {
    case 1:
      cin >> x;
      L.insert(x);
      balance();
      break;
    case 2:
      cin >> y;
      x = *S.rbegin();
      S.erase(prev(S.end()));
      S.insert(x + y);
      balance();
      break;
    case 3:
      cout << *S.rbegin() << '\n';
      break;
    }
  }
}
            
            
            
        