1#include"../../kyopro_library/template.hpp"
3#include <ext/pb_ds/assoc_container.hpp>
4#include <ext/pb_ds/tree_policy.hpp>
5using namespace __gnu_pbds;
25 return*
this->rbegin();
31 T ret=
min();
this->erase(ret);
38 T ret=
max();
this->erase(ret);
43 bool contains(T x) {
return this->find(x)!=
this->end(); }
47 auto itr=
this->find(x);
48 if(itr==
this->end())
return false;
55 auto itr=
this->upper_bound(x);
62 auto itr=
this->lower_bound(x);
69 auto itr=
this->lower_bound(x);
76 auto itr=
this->upper_bound(x);
82 int count_lt(T x) {
return this->order_of_key(x); }
85 int count_le(T x) {
return this->order_of_key(x+1); }
88 int count_gt(T x) {
return this->size()-
this->order_of_key(x+1); }
91 int count_ge(T x) {
return this->size()-
this->order_of_key(x); }
94 T
kth_min(
int k) {
return *
this->find_by_order(k); }
97 T
kth_max(
int k) {
return *
this->find_by_order(
this->size()-k-1); }
bool contains(T x)
x が含まれているか否かを返す
int count_le(T x)
x 以下の値の個数を返す
SortedTree(T not_found=-1)
コンストラクタ
T kth_max(int k)
k(0-indexed) 番目に大きい値の個数を返す
int count_gt(T x)
x より大きい値の個数を返す
T kth_min(int k)
k(0-indexed) 番目に小さい値の個数を返す
int count_ge(T x)
x 以上の値の個数を返す
int count_lt(T x)
x より小さい値の個数を返す