-->
当前位置:首页 > 题库

PROGRAMMING:Omar Eyre

Luz5年前 (2021-05-10)题库520
Omar likes to eat a lot of sweets, but unfortunately, most of them are unhealthy. So his parents found a way to rate each candy. The higher the score, the healthier the candy will be (the score is an integer, which can be positive, zero or negative). A child and his parents bought some candy. They went to the place where the candy was sold. All the candy was stored in an n * m two-dimensional grid with M candy in each row. Rows are numbered from 1 to n from top to bottom, columns are numbered from 1 to m from left to right, and each cell contains a candy health value. Strangely, the health value of candy in this two-dimensional grid always increases from top to bottom and from left to right, as shown in the following figure
![ Capture 2. PNG] (~ / 842e2cc7-5535-4cb3-af6c-20b431fb2fd9. PNG)
Omar wants to buy all the candy in a submatrix. Please program to find the biggest candy health value he can buy.
###Input format:
The first line of input is a single integer T, the number of test cases (1 ≤ t ≤ 100). At the beginning of each test case, one line contains spaces to separate two integers. N m (1 ≤ n, m ≤ 1000) represents the size of the candy grid, followed by N lines. Each line contains M spaces to separate integers, representing the health value of this line of candy. Each integer in the grid will be no less than - 2000 and no more than 2000.
###Output format:
For each test case, print a line containing a single integer that represents the maximum sum of health values that can be obtained from a non empty subrectangle.
###Input example:
Here is a set of inputs. For example:
```in
one
3 3
-4 -2 -1
-3 2 3
1 4 5
```
###Output example:
The corresponding output is given here. For example:
```out
fourteen
```







answer:If there is no answer, please comment