BOI 383

Problem A. Ponding Water
Description
There is a strange building on planet VOID. It is made up of N*M
rectangular parallelepipeds on N*M grids, whose bottom surfaces are 1*1
squares. Since heights of these rectangular parallelepipeds are different,
they form a number of “holes” inside the building. After a heavy rainfall
there will be some ponding water in these holes. You are asked to
calculate the maximum possible volume of the ponding water.
Top view of the building
ponding water is painted grey on the right figure


Input
There are multiple cases, end by EOF.
For each case, the first line contains two integers, N and M (1 <= N, M <=
100), length and width of the building respectively. Then N lines followed,
each of which contains M integers (these integers are between [0,
10000]), describing the height of each rectangular parallelepiped.
Output
For each case, you should output one integer in a line, the maximum
possible volume of the ponding water.
Sample Input
3 6
3 3 4 4 4 2
3 1 3 2 1 4
7 3 1 6 4 1
3 3
3 2 3
2 2 2
3 2 3
Sample Ouput
5

0


 


 

posted on 2012-03-24 22:28  c语言源码  阅读(162)  评论(0编辑  收藏  举报

导航