On an $N \times N$ grid of positive integers you move only right or down from $(1,1)$ to $(N,N)$. Print the maximum possible sum of the cells on a path.
Input
First line $N$ ($1 \le N \le 500$); then $N$ rows of $N$ integers, each in $[1, 1000]$.
Output
Print the maximum path sum.
Example 1
Input
3 1 3 2 2 5 1 4 2 1
Output
12
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.