#abc311g. G - One More Grid Task
G - One More Grid Task
Score : points
问题描述
存在一个 的网格,其中从上到下的第 行、从左到右的第 列有一个非负整数 。
让我们选择一个矩形区域 。形式上,该区域按照以下方式选定:
- 选择整数 使得 。
- 然后,如果满足条件 且 ,则第 个格子属于区域 。
求解 可能的最大值,其中 (区域内所有格子上整数之和)(区域内格子上最小的整数)。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is an grid, where the square at the -th row from the top and -th column from the left has a non-negative integer written on it.
Let us choose a rectangular region .
Formally, the region is chosen as follows.
- Choose integers such that .
- Then, square is in if and only if and .
Find the maximum possible value of (the sum of integers written on the squares in ) (the smallest integer written on a square in ).
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3 3
5 4 3
4 3 2
3 2 1
Sample Output 1
48
Choosing the rectangular region whose top-left corner is square and whose bottom-right corner is square achieves , which is the maximum possible value.
Sample Input 2
4 5
3 1 4 1 5
9 2 6 5 3
5 8 9 7 9
3 2 3 8 4
Sample Output 2
231
Sample Input 3
6 6
1 300 300 300 300 300
300 1 300 300 300 300
300 300 1 300 300 300
300 300 300 1 300 300
300 300 300 300 1 300
300 300 300 300 300 1
Sample Output 3
810000
update @ 2024/3/10 08:51:59