Description

Pour champagne into top glass of pyramid. Glasses overflow equally to two below. Return how full glass at row i, position j is.

Examples

Input:poured = 1, query_row = 1, query_glass = 1
Output:0.0
Explanation:

No overflow to (1,1).

Input:poured = 0, query_row = 0, query_glass = 0
Output:0.0
Explanation:

When no champagne is poured, even the top glass (0,0) remains empty.

Input:poured = 4, query_row = 2, query_glass = 0
Output:0.25
Explanation:

With 4 units poured: top glass gets 1 (overflows 3), row 1 glasses each get 1.5 (each overflows 0.5), so row 2 leftmost glass gets 0.5/2 = 0.25 from the glass above it.

Constraints

  • 0 ≤ poured ≤ 10⁹

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!