結果
| 問題 |
No.3298 K-th Slime
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 15:25:28 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,193 bytes |
| コンパイル時間 | 2,674 ms |
| コンパイル使用メモリ | 286,964 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-05 15:25:39 |
| 合計ジャッジ時間 | 5,548 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 RE * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INF = 2e9;
const ll LINF = 2e18;
#define rep(i, n) for (int i = 0; (i) < (n); (i)++)
#define rep1(i, n) for (int i = 1; (i) < ((n) + 1); (i)++)
#define all(a) (a).begin(), (a).end()
const int dx[] = {-1,0,1,0};
const int dy[] = {0,1,0,-1};
int main(){
ll N,K,Q;
cin>>N>>K>>Q;
vector<ll> A(N);
priority_queue<ll, vector<ll>, less<ll>> P1;
priority_queue<ll, vector<ll>, greater<ll>> P2;
rep(i,N){
cin>>A[i];
}
sort(all(A));
rep(i,N){
if(i < K){
P1.push(A[i]);
} else {
P2.push(A[i]);
}
}
while(Q--){
int q;
cin>>q;
if(q==1){
ll x;
cin>>x;
if(P1.top() > x){
auto t = P1.top();
P1.pop();
P1.push(x);
P2.push(t);
} else {
P2.push(x);
}
} else if(q==2){
ll y;
cin>>y;
auto t = P1.top();
auto u = P2.top();
if(t+y <= u){
P1.pop();
P1.push(t+y);
} else {
P1.pop();
P2.pop();
P1.push(u);
P2.push(t+y);
}
} else {
cout<<P1.top()<<endl;
}
}
}