Suppose you're given a population of $n$ points $(x_i, y_i)$ in the unit square $[0, 1]^2$. For a given new sample $(x, y)$, you must find the number of points in the original population satisfying $x\leqslant x_i$ and $y\leqslant y_i$.
Question: Can you beat the trivial $O(n)$ complexity under the constraints:
- memory: $O\big(n(\log n)^{O(1)}\big)$;
- pre-processing complexity: $O\big(n(\log n)^{O(1)}\big)$?
Illustration of the problem:
The one-dimension analogue is easily solved by first sorting the population ($O(n\log n)$ pre-processing) and then deducing the count from the position of the query in the sorted population ($O(\log n)$). This is not trivially extensible to multiple dimensions since treating the two dimensions independently requires to intersect 2 sets of (worst case) $O(n)$ elements in the end, which is not better than trivial.
An idea would be to partition the population into subsets either totally ordered (for $(x_1, y_1)\preccurlyeq (x_2, y_2) \Longleftrightarrow x_1\leqslant x_2 \land y_1\leqslant y_2$) or "totally unordered" (i.e. when a $y$-flip makes it totally ordered). This would give at most $O(n_{\text{subsets}}\log(n))$. Maybe there's a theorem providing an upper bound on such partition scheme?
Thanks in advance!