#2228. [Usaco2004 Jan]洪水

[Usaco2004 Jan]洪水

Description

农场面临着洪水的威胁。帮助约翰找到水的高度,他可以把他的奶牛移到安全的地方, 农场由M×N(1≤M,N≤400)

的单位方格组成.每格有一个海拔高度Hi,j(1≤Hi,j≤10000).给出一个M×N的表格地图和降水量V(1≤V≤10^9

)。水总是先注入最低的方格,不管该方格在哪儿。请你算出水面高度,水面和海平面之间的陆地体积(可能为0)

。注意:陆地和水面高度相同时已经被淹没。

Format

Input

  • Line 1: Three space-separated integers: M, N, and V

  • Lines 2...: Each line contains as many as 20 space-separated

      integers that represent the elevations of the farm. The first
    
      N integers are spread across line 1 and it successors, 20
    
      integers per line, until all N integers are laid out. The next
    
      N integers begin on a new line, etc.
    

Output

在一行内输出两个由空格分隔的整数:水面高度,海平面和水面之间陆地的体积(被水完全淹没的陆地体积)。

Samples

4 5 33
2 2 2 2 2
1 3 4 3 2
2 3 5 3 2
2 4 1 1 2
4 43

Limitation

The water will rise to a height of 4 m, submerging the blocks marked1, 2, 3, and 4.

The volume of land below the water is 13 + 210 + 34 +42 = 43.

水高4米,淹没的区域标记1,2,3,4.水下陆地的体积:1×3+2×10+3×4+4×2=43.