Embercode
✕
Linked ListsCoding problems

Linked Lists: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 8 solved

  • A train is made of carriages. Each carriage has a number on it. The guard walks the train from the engine to the last carriage and writes down two things: the total of all the numbers, and the biggest number.

    Build a linked list from the carriage numbers, in order, then walk it once.

    Constraints: 1 <= n <= 700. Each number is between -1000000000 and 1000000000. The total can be larger than an int, so use long long for it.

    Input. Line 1: `n`. Line 2: the `n` numbers in order.

    Output. One line with the total and the biggest number, separated by one space.

    Example 1 input

    5
    3 9 2 9 7
    

    Output

    30 9
    

    Example 2 input

    1
    -5
    

    Output

    -5 -5