#B001. 沙盘游戏Sand table game
沙盘游戏Sand table game
Sand table game
[Problem Description]
Ivy loves programming so much that she does the same when facing games. In the sandbox game, there is a huge square sandbox (rectangular or square) that is divided into small squares with a side length of 1, each square containing an integer. The sandbox player needs to circle a square (rectangular or square) area in the sandbox (must be drawn along the boundary of the small square, cannot pass through the inside of the small square), with the goal of maximizing the sum of integers in the circled area.
For ease of description, Ivy represents this sandbox as n * m integers, with each integer representing a small square with a side length of 1 in the sandbox.
Ivy now needs to program to solve a problem: select an x * y (x rows and y columns) square region from n * m (n rows and m columns) integers (x can reach a maximum of n, y can reach a maximum of m), so that the sum of these x * y integers is the largest among all available square regions, and output the maximum sum value.
[Input]
The first row contains two integers, n and m, separated by a space, representing the number of rows and columns contained in the original square area. There are n rows below, each consisting of m integers (each ranging from -200 to 200).
[Output]
One integer per line, representing the sum of integers at all positions in a circled square area. The value must be the one with the largest sum of integers corresponding to all circled square areas, and must not exceed 106.
[Input/Output Example]
in
3 3
10 -21 9
7 8 4
-6 1 0
out
nineteen
[Input/Output Example Description]
The circled square area is the third integer in the second row, namely 7, 8, and 4. The sum of these three numbers is 19, which is the maximum value of the sum of integers in all circled areas.
[Data Scale Description]
For 10% of the data, n,m<=5
For 40% of the data, n,m<=30
For 60% of the data, n,m<=40
For 90% of the data, n,m<=80
For 100% of the data, n,m<=280