eolymp
bolt
Try our new interface for solving problems
Problems

Maximum sum

Maximum sum

Given a table with integers of size $n \cdot n$. Find in it the rectangle with maximum sum. For example, in the table \includegraphics{https://static.e-olymp.com/content/b9/b99448ce127dd7dec0e16e9e5f072536c17fee44.gif} the rectangle with maximum sum is \includegraphics{https://static.e-olymp.com/content/85/85cf1a7729da04b7276590d60ca60edf30f5c690.gif} Sum of its elements equals to $15$. \InputFile First number $n~(n \le 500)$ is the size of the table. Then $n^2$ integers are given that describes the table. It is known that all numbers are integers in the range $[-127, 127]$. It is known that the table contains at least one nonnegative integer. \OutputFile Print the maximum sum in rectangle.
Time limit 1 second
Memory limit 128 MiB
Input example #1
4
0 -2 -7 0
9 2 -6 2
-4 1 -4 1
-1 8 0 -2
Output example #1
15