結果
問題 |
No.3298 K-th Slime
|
ユーザー |
|
提出日時 | 2025-10-05 16:39:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 922 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 83,368 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2025-10-05 16:39:07 |
合計ジャッジ時間 | 4,388 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 WA * 10 |
ソースコード
#include<iostream> #include<vector> #include<set> #include<algorithm> using namespace std; using ll = long long; int main(void){ int n, k, q; cin >> n >> k >> q; multiset<ll> small, big; big.insert(1e18); for(int i=0; i<n; i++){ ll a; cin >> a; small.insert(a); } auto f=[&](){ while(small.size()>k){ auto p=prev(small.end()); big.insert(*p); small.erase(p); } while(small.size()<k){ auto p=big.begin(); small.insert(*p); big.erase(p); } }; while(q--){ int t; cin >> t; if(t==1){ ll x; cin >> x; small.insert(x); f(); } else if(t==2){ ll y; cin >> y; auto p=prev(small.end()); auto q=big.begin(); ll ad=(*p)+y; small.erase(p); small.insert(ad); small.insert(*q); big.erase(q); f(); } else{ cout << *small.rbegin() << '\n'; } } return 0; }