You can solve the problem without using floating point calculations. in32 is enough for everything.

You also needn't to implement BSTrees or Segment trees here. Using ordered sets is enough.

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

typedef __gnu_pbds::tree<

Point,

__gnu_pbds::null_type,

std::less_equal<>,

__gnu_pbds::rb_tree_tag,

__gnu_pbds::tree_order_statistics_node_update> ordered_set_less;

typedef __gnu_pbds::tree<

Point,

__gnu_pbds::null_type,

std::greater_equal<>,

__gnu_pbds::rb_tree_tag,

__gnu_pbds::tree_order_statistics_node_update> ordered_set_greater;