#P1216. [IOI 1994 / USACO1.5] 数字三角形 Number Triangles
[IOI 1994 / USACO1.5] 数字三角形 Number Triangles
Description
Look at the number pyramid below.
Write a program to find a path from the top to any position on the bottom that yields the maximum possible sum of the numbers along the path. At each step, you may move to the left-down or right-down adjacent position.

In the sample above, the path produces the maximum sum.
Input Format
The first line contains a single integer , the number of rows.
Each of the next lines describes one row of the number triangle: for each from to , the -th line contains integers.
Output Format
Output a single line containing the maximum possible sum.
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
30
Hint
Constraints
For of the testdata, , and all input integers are in the range .
Problem translation from NOCOW.
IOI 1994 Day 1 T1 / USACO Training Section 1.5.
Translated by ChatGPT 5
京公网安备 11011102002149号