1324. Water

单点时限: 2.0 sec

内存限制: 256 MB

On a rectangular mesh comprising nm fields, nm cuboids were put, one cuboid on each field. A base of each cuboid covers one field and its surface equals to one square inch. Cuboids on adjacent fields adhere one to another so close that there are no gaps between them. A heavy rain pelted on a construction so that in some areas puddles of water appeared.

Task

Write a program which:

1.reads a size of the chessboard and heights of cuboids put on the fields,

2.computes maximal water volume, which may gather in puddles after the rain,

3.writes results.

输入格式

In the first line two positive integers 1 <= n <= 100, 1 <= m <= 100 are written. They are the size of the mesh. In each of the following n lines there are m integers from the interval [1..10000]; i-th number in j-th line denotes a height of a cuboid given in inches put on the field in the i-th column and j-th raw of the chessboard.

输出格式

Your program should write in the first and the only line one integer equal to the maximal volume of water (given in cubic inches), which may gather in puddles on the construction.

样例

Input
3 6
3 3 4 4 4 2
3 1 3 2 1 4
7 3 1 6 4 1
Output
5

4 人解决,8 人已尝试。

6 份提交通过,共有 18 份提交。

8.1 EMB 奖励。

创建: 16 年,8 月前.

修改: 6 年,8 月前.

最后提交: 3 年,4 月前.

来源: POI 1999 III Stage

题目标签