Glasses are stacked in a pyramid: row 0 has one glass, row 1 has two, and so on up to row 99. Each glass holds one cup. You pour `poured` cups into the top glass. When a glass is full, any extra liquid splits equally and falls into the two glasses just below it (left and right). Return how full the glass at index `query_glass` in row `query_row` is (both 0-indexed), as a number between 0 and 1.
Glasses are stacked in a pyramid: row 0 has one glass, row 1 has two, and so on up to row 99. Each glass holds one cup. You pour poured cups into the top glass. When a glass is full, any extra liquid splits equally and falls into the two glasses just below it (left and right). Return how full the glass at index query_glass in row query_row is (both 0-indexed), as a number between 0 and 1.
Example 1:
Input: {"poured":1,"query_row":1,"query_glass":1}
Output: 0.0
Constraints:
0≤poured≤109
0≤query_glass≤query_row<100
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"poured":1,"query_row":1,"query_glass":1}
poured
1
rows settled
0 / 1
glass (1, 1)
?
r0
r1
numbers = how full (max 1)┅ query glass
The tower is empty. We will track the total amount that flows into each glass, not just what it keeps, down to row 1.