Codeforces Round 131 (Div. 1)
C
Relay Race
Codeforces
2000
原题
← BD →
翻译中…

Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of $*n*$ meters. The given square is split into $*n* × *n*$ cells (represented as unit squares), each cell has some number.

翻译中…

At the beginning of the race Furik stands in a cell with coordinates $(1, 1)$, and Rubik stands in a cell with coordinates $(*n*, *n*)$. Right after the start Furik runs towards Rubik, besides, if Furik stands at a cell with coordinates $(*i*, *j*)$, then he can move to cell $(*i* + 1, *j*)$ or $(*i*, *j* + 1)$. After Furik reaches Rubik, Rubik starts running from cell with coordinates $(*n*, *n*)$ to cell with coordinates $(1, 1)$. If Rubik stands in cell $(*i*, *j*)$, then he can move to cell $(*i* - 1, *j*)$ or $(*i*, *j* - 1)$. Neither Furik, nor Rubik are allowed to go beyond the boundaries of the field; if a player goes beyond the boundaries, he will be disqualified.

翻译中…

To win the race, Furik and Rubik must earn as many points as possible. The number of points is the sum of numbers from the cells Furik and Rubik visited. Each cell counts only once in the sum.

翻译中…

Print the maximum number of points Furik and Rubik can earn on the relay race.

翻译中…

Input

翻译中…

The first line contains a single integer $(1 ≤ *n* ≤ 300)$. The next $*n*$ lines contain $*n*$ integers each: the $*j*$-th number on the $*i*$-th line $*a*_{*i*, *j*}$ $( - 1000 ≤ *a*_{*i*, *j*} ≤ 1000)$ is the number written in the cell with coordinates $(*i*, *j*)$.

翻译中…

Output

翻译中…

On a single line print a single number — the answer to the problem.

翻译中…

Note

翻译中…

Comments to the second sample: The profitable path for Furik is: $(1, 1)$, $(1, 2)$, $(2, 2)$, and for Rubik: $(2, 2)$, $(2, 1)$, $(1, 1)$.

翻译中…

Comments to the third sample: The optimal path for Furik is: $(1, 1)$, $(1, 2)$, $(1, 3)$, $(2, 3)$, $(3, 3)$, and for Rubik: $(3, 3)$, $(3, 2)$, $(2, 2)$, $(2, 1)$, $(1, 1)$. The figure to the sample:

翻译中…

image

翻译中…

Furik's path is marked with yellow, and Rubik's path is marked with pink.

翻译中…

样例

Input #1
1
5
Output #1
5
InputCopy OutputCopy
Input #2
2
11 14
16 12
Output #2
53
InputCopy OutputCopy
Input #3
3
25 16 25
12 18 19
11 13 8
Output #3
136
InputCopy OutputCopy
题目信息
题号
213C
时间限制
4 s
内存限制
256 MB
标签
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。