結果

問題 No.618 labo-index
ユーザー pekempeypekempey
提出日時 2017-12-18 23:17:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 963 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 125,256 KB
実行使用メモリ 10,180 KB
最終ジャッジ日時 2023-08-22 06:07:29
合計ジャッジ時間 9,686 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 356 ms
10,148 KB
testcase_35 AC 351 ms
10,180 KB
testcase_36 AC 340 ms
7,008 KB
testcase_37 AC 278 ms
6,976 KB
testcase_38 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
}
0