結果
問題 |
No.3298 K-th Slime
|
ユーザー |
|
提出日時 | 2025-10-07 13:22:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 172 ms / 2,000 ms |
コード長 | 1,326 bytes |
コンパイル時間 | 4,723 ms |
コンパイル使用メモリ | 325,444 KB |
実行使用メモリ | 13,016 KB |
最終ジャッジ日時 | 2025-10-07 13:22:57 |
合計ジャッジ時間 | 7,642 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; // Order Statistic Tree 定義(SortedList 相当) template <class T> using ordered_multiset = tree< T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long N, K, Q; cin >> N >> K >> Q; ordered_multiset<long long> A; for (int i = 0; i < N; i++) { long long x; cin >> x; A.insert(x); } vector<long long> ans; for (int i = 0; i < Q; i++) { int t; cin >> t; if (t == 1) { long long x; cin >> x; A.insert(x); } else if (t == 2) { long long y; cin >> y; // K-1 番目(0-indexed)の要素を取り出す auto it = A.find_by_order(K - 1); long long a = *it; // その要素を削除 A.erase(it); // a + y を挿入 A.insert(a + y); } else { // t == 3 auto it = A.find_by_order(K - 1); ans.push_back(*it); } } for (auto x : ans) cout << x << "\n"; }