結果

問題 No.3298 K-th Slime
ユーザー Iroha_3856
提出日時 2025-10-05 14:19:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 2,082 bytes
コンパイル時間 6,145 ms
コンパイル使用メモリ 352,328 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2025-10-05 14:19:47
合計ジャッジ時間 8,886 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = atcoder::modint998244353;
// using mint = double;

//PBDS-tree
#if __has_include(<ext/pb_ds/assoc_container.hpp>)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//tree.find_by_order(k) = tree[k] (0-indexed)
//tree.order_of_key(k) = tree.lower_bound(k) - tree.begin()
//Note: Can only be used for non-multiple sets.
#endif

#define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++)
#define ll long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define siz(x) (int)(x).size()

template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int inf = 1e9;
const ll INF = 4e18;

template<class T> using pq = priority_queue<T, vector<T>, less<T>>;
template<class T> using spq = priority_queue<T, vector<T>, greater<T>>;

vector<int> di = {0, 0, 1, -1};
vector<int> dj = {1, -1, 0, 0};

struct Edge {
    int to, cost;
};

void solve() {
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    Tree<pair<ll, int>> T;
    rep(i, 0, N) T.insert({A[i], i});
    int id = N;
    while(Q--) {
        int q; cin >> q;
        if (q == 1) {
            ll x; cin >> x;
            T.insert({x, id});
            id++;
        }
        if (q == 2) {
            ll y; cin >> y;
            auto itr = T.find_by_order(K-1);
            T.insert({itr->first + y, itr->second});
            T.erase(itr);
        }
        if (q == 3) {
            cout << T.find_by_order(K-1) -> first << endl;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
}
0