#abc358g. G - AtCoder Tour
G - AtCoder Tour
Score : points
问题陈述
AtCoder Land 由一个 行 列的网格表示。用 表示第 行第 列的单元格。
高桥从单元格 开始,重复以下动作 次:
- 他要么留在当前单元格,要么移动到相邻单元格。在执行这个动作后,如果他在单元格 ,他将获得一个乐趣值 。
找出他可以获得的最大总乐趣值。
这里,如果 ,则认为单元格 与单元格 相邻。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
AtCoder Land is represented by a grid with rows and columns. Let denote the cell at the -th row and -th column.
Takahashi starts at cell and repeats the following action times:
- He either stays in the current cell or moves to an adjacent cell. After this action, if he is in cell , he gains a fun value of .
Find the maximum total fun value he can gain.
Here, a cell is considered adjacent to cell if and only if .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 3 3
1 2
2 1 2
3 4 5
Sample Output 1
14
Takahashi can gain a total fun value of by acting as follows:
- Initially, he is at .
- He moves to cell . Then, he gains a fun value of .
- He moves to cell . Then, he gains a fun value of .
- He stays in cell . Then, he gains a fun value of .
He cannot gain a total fun value greater than , so print .
Sample Input 2
2 2 1000000000
2 1
100 100
100 99
Sample Output 2
100000000000