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

PROGRAMMING:To the Max

Luz5年前 (2021-05-10)题库444
Given a two-dimensional array composed of positive and negative integers, a sub rectangle is located in the integer
Any continuous subarray of size 1 * 1 or greater in an array. The sum of the rectangles is the sum of the rectangles
There is a sum of elements. In this problem, the sub rectangle with the largest sum is called the largest sub rectangle.
For example, give a two-dimensional array as follows:
0 -2 -7 0
9 2 -6 2
-4 1 -4 1
-1 8 0 -2
The largest sub rectangle is in the lower left corner:
9 2
-4 1
-1 8
The sum of rectangles is 15.
###Input format:
Input to give an array of n * n integers. The first line of input gives a positive integer n, which represents the size of the two-dimensional square array. N2 integers separated by white space (space and newline) are given later. These integers are the N2 of the array
An integer, given row by row in behavioral order. That is to say, first of all, the first row gives all the numbers in the first row from left to right; Then, the second line from left to right gives all the numbers in the second line, and so on, the maximum value of N can be 100. The range of numbers in the array is [- 127, 127].
###Output format:
Outputs the sum of the largest subrectangles.
###Input example:
Here is a set of inputs. For example:
```in
four
0 -2 -7 0
9 2 -6 2
-4 1 -4 1
-1 8 0 -2
```
###Output example:
The corresponding output is given here. For example:
```out
fifteen
```







answer:If there is no answer, please comment