HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50816 - Largest Sum Path

Guest
• Review clarifications (1)

Volume problems

• 50818 - Depth Limited BST
• 50836 - Censored
• 50505 - kht Puzzle
• 50840 - Tanker trucks
• 50877 - Friendly Queue
• 50876 - He is my cousin
• 50997 - Dynamic Knights
• 50490 - Across the River
• 50816 - Largest Sum Path
• 50857 - Nine-Stones Game
• 50837 - Sum is equal to K
• 50772 - The Path of a Node
• 50936 - Saving the Soldiers
• 50447 - Swimming Contest - 2
• 50828 - Arranging Time Table
• 50794 - Writing Files Into HDD
• 50929 - Present from your uncles

Feedback

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

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Largest Sum Path

Path sum is the sum of the numbers on a path in BST. For example the sum of the numbers

  15 + 12 + 14 + 13 = 54
is the largest path sum according to the given BST.

Question: Write a program to find the largest path sum in a given BST.

Input specification
In the first line, you will be given an integer (n) The number of numbers in the BST where 0 ≤ n ≤ 1e4. Then, in the following n lines, you will be given n integers which are between -1e4 and 1e4.

Output specification
Show one number: Largest path sum.

Sample Input I
10
15
17
15
12
14
12
16
1
17
13
Sample Output I
54



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

www.contester.ru