結果

問題 No.3298 K-th Slime
ユーザー ZOI-dayo
提出日時 2025-10-05 14:01:11
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 2,193 bytes
コンパイル時間 3,057 ms
コンパイル使用メモリ 287,380 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2025-10-05 14:01:19
合計ジャッジ時間 5,957 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vl = vector<ll>;
template <class T> using vec = vector<T>;
template <class T> using vv = vec<vec<T>>;
template <class T> using vvv = vv<vec<T>>;
template <class T> using minpq = priority_queue<T, vec<T>, greater<T>>;
#define rep(i, r) for(ll i = 0; i < (r); i++)
#define reps(i, l, r) for(ll i = (l); i < (r); i++)
#define rrep(i, l, r) for(ll i = (r) - 1; i >= (l); i--)
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)(a).size()
template<typename T>
bool chmax(T &a, const T& b) { return a < b ? a = b, true : false; }
template <typename T>
bool chmin(T &a, const T& b) { return a > b ? a = b, true : false; }
ll modmul(ll a, ll b, ll mod) {
	ll ret = a * b - mod * ll(1.L / mod * a * b);
	return ret + mod * (ret < 0) - mod * (ret >= mod);
}
ll modpow(ll a, ll b, ll mod) {
	ll ans = 1;
	for (; b; a = modmul(a, a, mod), b /= 2)
		if (b & 1) ans = modmul(ans, a, mod);
	return ans;
}

using ull = unsigned long long;

int solve() {
    ll n, k, q;
    cin >> n >> k >> q;
    vl a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    multiset<ll> first, second;
    rep(i, n) {
        if(i < k) first.insert(a[i]);
        else second.insert(a[i]);
    }
    rep(Q, q) {
        ll type;
        cin >> type;
        if(type == 1) {
            ll x;
            cin >> x;
            first.insert(x);
            ll last = *--first.end();
            first.erase(--first.end());
            second.insert(last);
        }
        if(type == 2) {
            ll y;
            cin >> y;
            ll last = *--first.end();
            last += y;
            first.erase(--first.end());
            if(second.empty() || last <= *second.begin()) {
                first.insert(last);
            } else {
                first.insert(*second.begin());
                second.erase(second.begin());
                second.insert(last);
            }
        }
        if(type == 3) {
            cout << *--first.end() << endl;
        }
    }
    return 0;
}

int main() {
	ll T = 1;
	cout << fixed << setprecision(16);
	// cin >> T;
	while (T--) solve();
}
0