結果
| 問題 |
No.3298 K-th Slime
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 15:31:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 262 ms / 2,000 ms |
| コード長 | 960 bytes |
| コンパイル時間 | 1,941 ms |
| コンパイル使用メモリ | 229,428 KB |
| 実行使用メモリ | 13,440 KB |
| 最終ジャッジ日時 | 2025-10-05 15:31:36 |
| 合計ジャッジ時間 | 5,093 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
#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;
using namespace std;
using ll = long long;
int main() {
ll N, K, Q;
cin >> N >> K >> Q;
vector<ll> A(N);
for (int i = 0; i < N; ++i) cin >> A[i];
tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> s;
for(int i = 0; i < N; i++){
s.insert({A[i], i});
}
while(Q--){
ll t;
cin >> t;
if(t == 1){
ll x;
cin >> x;
s.insert({x, N});
N++;
} else if(t == 2){
ll y;
cin >> y;
auto it = s.find_by_order(K-1);
auto [k, i] = *it;
s.erase(it);
s.insert({k + y, i});
} else{
cout << s.find_by_order(K-1)->first << "\n";
}
}
return 0;
}