結果
| 問題 | No.618 labo-index | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-12-18 23:44:58 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 373 ms / 6,000 ms | 
| コード長 | 996 bytes | 
| コンパイル時間 | 1,496 ms | 
| コンパイル使用メモリ | 126,628 KB | 
| 実行使用メモリ | 11,096 KB | 
| 最終ジャッジ日時 | 2024-12-16 00:55:10 | 
| 合計ジャッジ時間 | 8,309 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 35 | 
ソースコード
#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;
  vector<pair<long long, int>> tmp;
  long long u = 0;
  for (int i = 0; i < q; i++) {
    int t;
    long long x;
    cin >> t >> x;
    if (t == 1) {
      int j = tmp.size();
      tmp.emplace_back(x - u, j);
      st.insert(make_pair(x - u, j));
    } else if (t == 2) {
      st.erase(tmp[x - 1]);
    } else {
      u += x;
    }
    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;
  }
}
            
            
            
        