Water filling problem in Blocks - Algebra Question

608 Views Asked by At

Consider a rectangular plot comprising $n\times m$ square cells on which $nm$ cement blocks of various heights are stored, one block per cell. The base of each block covers one cell completely, and blocks on adjacent cells are so close that there are no gaps between them. Due to a heavy rain on the construction, water is accumulated in the gaps created between the blocks due to the difference in their heights.

The question is how much water remains after the rain is over.

Problem Picture

The question is in 2 parts with different measures of cubes and block area

Q A) Plot Breadth = 3 Plot Length = 6

Plot Block height

3 3 4
4 4 2
3 1 3
2 1 4
7 3 1
6 4 1

Answer is written as 5.

Q B)

Plot Breadth = 6 Plot Length = 3

3 3 7 3 1 3
4 3 1 4 2 6
4 1 4 2 4 1

Answer 5

I tried solving it by choosing the minimum difference in heights but my answer is not equal anything that is given. For the first problem my answer seems to be 2 and it is given as 5. :S

Would appreciate if anyone could help