結果

問題 No.618 labo-index
ユーザー nebukuro09nebukuro09
提出日時 2018-01-13 10:25:43
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 943 bytes
コンパイル時間 3,221 ms
コンパイル使用メモリ 159,284 KB
実行使用メモリ 11,424 KB
最終ジャッジ日時 2023-09-03 18:09:05
合計ジャッジ時間 12,798 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto Q = readln.chomp.to!int;
    auto rbt = new RedBlackTree!(long, "a < b", true)();
    long offset = 0;
    long[] L;

    foreach (_; 0..Q) {
        auto s = readln.split;
        auto t = s[0].to!int;
        auto x = s[1].to!long;
        if (t == 1) {
            L ~= x - offset;
            rbt.insert(x - offset);
        } else if (t == 2) {
            rbt.removeKey(L[x.to!int-1]);
        } else {
            offset += x;
        }

        long hi = 10L^^5+1;
        long lo = 0;

        while (hi - lo > 1) {
            auto mid = (hi + lo) / 2;
            auto lb = rbt.upperBound(mid-offset-1).array.length;
            if (lb >= mid) lo = mid;
            else hi = mid;
        }

        max(0, lo).writeln;
    }
}

0