#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; using mint = atcoder::modint998244353; // pbds tree #include #include template using pbds_tree = __gnu_pbds::tree, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; void solve() { int n, k, q; cin >> n >> k >> q; k--; pbds_tree> tr; int cnt = 0; rep(i, 0, n) { ll a; cin >> a; tr.insert({a, cnt++}); } rep(Qi, 0, q) { int t; cin >> t; if (t == 1) { int x; cin >> x; tr.insert({x, cnt++}); } if (t == 2) { int y; cin >> y; auto itr = tr.find_by_order(k); auto [sz, id] = *itr; tr.erase(itr); tr.insert({sz + y, id}); } if (t == 3) { auto itr = tr.find_by_order(k); cout << itr->first << '\n'; } } } int main() { int t = 1; // cin >> t; while (t--) solve(); }