#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set; int main() { ordered_set OS; for (int i=10; i>0; --i) OS.insert( 10*i ); // vlozi 100, 90, ...., 10 for (int i=0; i<10; ++i) cout << * OS.find_by_order(i) << endl; // 10, ..., 90, 100 cout << endl; for (int i=5; i<=105; i+=5) cout << OS.order_of_key(i) << endl; // 0, 0, 1, 1, ..., 9, 9, 10 }