結果
問題 |
No.618 labo-index
|
ユーザー |
|
提出日時 | 2017-12-18 23:17:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 963 bytes |
コンパイル時間 | 3,460 ms |
コンパイル使用メモリ | 126,252 KB |
実行使用メモリ | 10,240 KB |
最終ジャッジ日時 | 2024-12-16 00:54:23 |
合計ジャッジ時間 | 10,150 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 30 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<class T> using Set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { int q; cin >> q; Set<pair<long long, int>> st; long long u = 0; vector<long long> x(q); for (int i = 0; i < q; i++) { int t; cin >> t >> x[i]; if (t == 1) { x[i] -= u; st.insert(make_pair(x[i], i)); } else if (t == 2) { st.erase(st.find(make_pair(x[x[i] - 1], x[i] - 1))); } else { u += x[i]; } long long ok = 0; long long ng = 2e5; while (ng - ok > 1) { int mid = (ok + ng) / 2; int cnt = st.size() - st.order_of_key(make_pair(mid - u, 0)); if (cnt >= mid) { ok = mid; } else { ng = mid; } } cout << ok << endl; } }