joj2511

来源:互联网 发布:学历网络教育报名费用 编辑:程序博客网 时间:2024/06/02 01:43

 2511: Number triangle


ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE1s65536K427217Standard
        5      3   4    8   1   2  5   4   3   62   1   7   9   8

A number trangle is composed of N(N<=100) line numbers, the i-th line contains i positive integers(<=100). A chess can walk from the top line of the triangle to the bottom line. Suppose the chess is on the k-th number of one line, then it can only move to the k-th number or the (k+1)-th number of the line below in one step. Find a path from the top to the bottom, which can maximize the sum of the integers on the path.

Input

There are multiple test cases.For each test case, there's an integer N representing the size of the triangle, followed by N lines of positive intergers, the first line has 1 integer, next has two integers... the Nth line has N integers.

Output

The maximum sum of the integers on the path.

Sample Input

357 02 4 3326 12 3 9

Sample Output

1612