Stars
From POJ. Shape / 2D. Solve the geometry problem "Stars".
Examples
Input: [1,2,3]
Output: 0
Input: [2,3,4]
Output: 0
Hints
Star "level" = count of stars with x' ≤ x and y' ≤ y (strictly less for equal coords? Check problem — typically includes stars with ≤ both axes, excluding itself). Sort by y ascending, process left to right.
After sorting by y, only x matters. Use Fenwick tree (BIT) over x range. For each star in order: query BIT sum up to star.x for level, then update BIT at star.x with +1.
Coordinates may be 0-based; BIT needs 1-indexed, shift x by +1. Compress x coordinates if range large (N ≤ 15000). Output array count[0..N-1] where count[l] = number of stars at level l.
Stars
**From POJ.** Shape / 2D. Solve the geometry problem "Stars".