QOJ.ac

QOJ

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

#22715. Tam giác số

Statistics

Xét tam giác số bên dưới. Viết chương trình tính tổng lớn nhất của các số trên đường đi bắt đầu ở đỉnh và kết thúc tại một vị trí bất kỳ trên đáy. Mỗi bước đi chéo xuống trái hoặc xuống phải.

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

Trong ví dụ, đường đi qua 7, 3, 8, 7, 5 cho tổng lớn nhất: 30.

Dữ liệu vào

Dòng đầu chứa số hàng $R$ ($1 \le R \le 1000$). Mỗi dòng tiếp theo chứa các số nguyên của hàng tương ứng trong tam giác. Tất cả không âm và không lớn hơn 100.

Dữ liệu ra

Một dòng chứa tổng lớn nhất theo cách di chuyển đã nêu.

Ví dụ

Dữ liệu vào 1

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

Dữ liệu ra 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.