Responsive image

问题 1240 --Interesting Punch-Bowl

1240: Interesting Punch-Bowl

时间限制: 1 Sec  内存限制: 128 MB
提交: 1  解决: 1
[提交][状态][讨论版][命题人:]

题目描述

 Dr.Kong has taken a side job designing interesting punch-bowl designs. The designs are created as follows:

      * A flat board of size W cm *  H cm is procured        (3 <= W <= 300, 3 <= H <= 300)

      * On every 1 cm x 1 cm square of the board, a 1 cm x 1 cm block is placed.  This block has some integer height B     (1 <= B <= 1,000,000,000)

The blocks are all glued together carefully so that punch will not drain  through them. They are glued so well, in fact, that the corner blocks really don't matter!

Dr.Kong can never figure out, however, just how much punch their bowl designs will hold. Presuming the bowl is freestanding (i.e., no special walls around the bowl), calculate how much juice the bowl can hold.  Some juice bowls, of course, leak out all the juice on the edges and will hold 0.

输入描述

 * Line 1: Two space-separated integers, W and H
* Lines 2..H+1: Line i+1 contains row i of bowl heights: W space-separated integers each of which represents the height B of a square in the bowl. The first integer is the height of column 1, the second integers is the height of column 2, and so on.
There are several test cases and end with the end of the file.

输出描述

 * Line 1: A single integer that is the number of cc's the described bowl will hold.

样例输入

4 5 
5 8 7 7
5 2 1 5
7 1 7 1
8 9 6 9
9 8 9 9

样例输出

12

提示

 河南省第五届ACM程序设计大赛

来源

[提交][状态]
ACM算法攻关部
  • Anything about this OnlineJudge, Please Contact Administrator. Click add QQ

    OJ system based on HUSTOJ Project , UI based on Twitter Bootstrap

    Copyright 2016 ACM算法攻关部
    关于网站改版