Comments

Hi, could you please elaborate on the O(n) solution for problem D?

I understand the O(n log n) idea, and I can imagine getting O(n) if we use counting sort because coordinates are in [1, n]. But I do not understand the intended O(n) observation from the editorial.

Specifically:

  1. What exactly are "the two groups determined by the smaller y-coordinate"?

  2. What does it mean that a valid dividing line must cross one of these groups?

  3. What point are we enumerating?

  4. What is the "appropriate pre-computation"? Which values should be precomputed?

  5. How do these precomputed values give the feasible vertical dividing position x?