~/algor $ cat problems/dp-sonlar-uchburchagi
Number triangle
Easy
1000 ms
128 MB
33%
A number triangle with $n$ rows is given: row $i$ contains $i$ numbers. Starting from the top of the triangle, at every step you move down to one of the two adjacent numbers of the row below — straight down or down-right — until you reach the last row. What is the largest possible sum of the numbers on the path?
Input
The first line contains a positive integer $n$. The $i$-th of the next $n$ lines contains $i$ integers.
Output
One integer — the largest sum.
Note
$1 \le n \le 500$
the numbers are from $-1000$ to $1000$
Examples
Input #1
4 7 3 8 8 1 0 2 7 4 4
Output #1
25
Input #2
1 -5
Output #2
-5