tiles[i] = [x, y, l] has its bottom-left corner at (x, y) and side length l. Tiles may overlap: each tile's area counts on its own, even where another tile covers it.
Draw a horizontal line at height h. The total area of the tile parts above the line must equal the total area of the parts below it.
Return the smallest such h. Answers within 10⁻⁵ of the true value are accepted.tiles=[[0, 0, 2], [5, 4, 2]] → 2.0
Each tile has area 4, so 4 of the total 8 must lie below the line. The lower tile is fully below height 2 and nothing lies between 2 and 4, so the lowest suitable line is at height 2.
tiles=[[3, 1, 4]] → 3.0
A single tile spanning heights 1 to 5 is split in half exactly in the middle, at height 3.
tiles=[[0, 0, 2], [1, 0, 2]] → 1.0
The tiles overlap, but each one's area counts separately, 8 in total. Both span heights 0 to 2, so the line at height 1 cuts each of them in half.
tiles.length ≤ 5·10⁴tiles[i] = [x, y, l]x, y ≤ 10⁹l ≤ 10⁹tiles=[[0, 0, 2], [5, 4, 2]]
2.0
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.