QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22715. 数の三角形

Statistics

次の数の三角形を考えてください。頂点から始まり底辺のどこかで終わる経路が通る数の合計の最大値を計算するプログラムを書いてください。各ステップでは左下または右下へ斜めに進めます。

        7
      3   8
    8   1   0
  2   7   4   4
4   5   2   6   5

上の例では、7、3、8、7、5 を通る経路の合計が最大の 30 になります。

入力

最初の行は行数 $R$($1 \le R \le 1000$)です。以降の各行には三角形の対応する行の整数が与えられます。すべて非負で 100 以下です。

出力

指定された移動で得られる最大の合計を一行に出力してください。

入出力例

入力 1

5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5

出力 1

30

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.