There is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so on i.e.
1
2 3
4 5 6
Every cup has capacity C, you pour L liters of water from top. When cup 1 gets filled , it overflows to cup 2,3 equally, and when they get filled, cup 4 and 6 get water only from 2 and 3 respectively but 5 gets water from both the cups and so on.
Now given C and L, problem is to find the amount of water in ith cup.
The solution to this can be though in terms of Pascal’s triangle. On the top water is coming directly into cup 1. At level-2 water will be equally divided into two cups. At level-3, water will come in 3 cups, and the ratio of water will be 1:2:1. i.e the middle cup will get twice as much water as the left and right (this does not change the capacity, just the water flowing in it).
If each glass can contain 1 unit of water, and you pour 15 units of water, you get the following (overflow amount in parenthesis):
Incoming flow = 15, capacity = 1
Level 1: 1(14)
Level 2: 1(6) 1(6)
Level 3: 1(2) 1(5) 1(2)
Level 4: 1(1) 1(2.5) 1(2.5) 1(1)
Level 5: 1 1(0.75) 1(1.5) 1(0.75) 1
Level 6: 0 0.375 1(0.125) 1(0.125) 0.375 0
Level 7: 0 0 0.0625 0.125 0.0625 0 0
The incoming flow from cup c on level r is Fin(c, r), and could be written as:
Fin(c, r) = Fout(c - 1, r - 1)/2 + Fout(c, r - 1)/2
where Fout is amopunt of outgoing water. The amount of water in that cup is:
A(c, r) = Min(C, Fin(c, r))
And the outgoing flow is:
Fout(c, r) = Max(0, Fin(c, r) - C)