結果
問題 |
No.618 labo-index
|
ユーザー |
|
提出日時 | 2018-01-13 10:25:43 |
言語 | D (dmd 2.109.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 943 bytes |
コンパイル時間 | 1,888 ms |
コンパイル使用メモリ | 159,744 KB |
実行使用メモリ | 10,112 KB |
最終ジャッジ日時 | 2024-06-12 23:33:10 |
合計ジャッジ時間 | 12,956 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 TLE * 1 -- * 18 |
ソースコード
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; } }