3453. Separate Squares I

Practice Separate Squares I for free on NudgeCode: Medium, Binary Search pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Each squares[i] = [x, y, l] is an axis-aligned square with bottom-left corner (x, y) and side length l. Find the minimum y-coordinate of a horizontal line such that the total area of the squares above the line equals the total area below it.

Squares may overlap; overlapping area is counted once per square (each square contributes its own area). Answers within 1e-5 are accepted.

Example

squares = [[0,0,1],[2,2,1]]  ->  1.0
squares = [[0,0,2],[1,1,1]]  ->  1.16667

(In the second case, below y = 7/6 the areas are 7/3 + 1/6 = 2.5; above, 5/3 + 5/6 = 2.5.)

Constraints