Question:
We will give you some line segments parallel to the X axis. Each time you ask about the height and of the first K line segments above the X coordinate. The question must be online.
Ideas:
First, we need to persist the line segment tree (also known as the Chairman tree and functional Line Segment tree). We can't do anything about poj 2104.
Discretize the height of all line segments and create a line segment tree as a node. Create two Chairman trees. One is to insert the height of the Left endpoint of a line segment into the chair tree, and the other is to insert the height of the right endpoint of the line segment into the chair tree, then, when we ask about the coordinates x, what we actually want to ask is the first chair tree minus the first K height and, if you don't understand it, you can draw what each tree represents on the paper and then you will understand it.