HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Albanian National Olympiads in Informatics > problem:


2012-4. 50680 - Triangle

Guest
• Discussion of problem (1)

Volume problems

• 2010-3. 50300 - Matrix
• 2012-2. 50545 - Diet
• 2013-1. 50591 - Leap year
• 2013-3. 50570 - Prime numbers in t...
• 2013-4. 50958 - ATM
• 2013-5. 50543 - Hotel rooms
• 2013-6. 50562 - List of students
• 2012-1. 50544 - Stock market
• 2012-4. 50680 - Triangle
• 2012-5. 50551 - Camelot
• 2014-2. 50738 - Median value
• 2012-3. 50721 - Palindrome

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/7000/7000/7000 ms. Memory limit 65000/65000/65000/65000 Kb.
Olympiad 2012. Prepared by: Evis Hoxha. Difficulty Beta

Question 4. Triangle

Shqip

Given a triangle like the one below:

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

Write a program that calculates the maximum sum of the numbers that can be obtained by following a way that starts in the vertex of the triangle and ends in a point in the base. Each step proceeds diagonal down: left or right.

Input

In the first line is given a number n, the number of the lines of the triangle, where 1<n<=100.
Then in the following n lines the values of the triangle are given. Each value is between 0 and 9.

Output

Show the maximal sum.

Input I

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

Output 1

30


Для отправки решений необходимо выполнить вход.

www.contester.ru