#include using namespace std; #include using namespace atcoder; using mint = atcoder::modint998244353; // using mint = double; //PBDS-tree #if __has_include() #include #include #include using namespace __gnu_pbds; template using Tree = tree, 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 bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1e9; const ll INF = 4e18; template using pq = priority_queue, less>; template using spq = priority_queue, greater>; vector di = {0, 0, 1, -1}; vector dj = {1, -1, 0, 0}; struct Edge { int to, cost; }; void solve() { int N, K, Q; cin >> N >> K >> Q; vector A(N); rep(i, 0, N) cin >> A[i]; Tree> 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(); } }