#C310. Find Peak and Trough

    ID: 46490 Type: Default 1000ms 256MiB

Find Peak and Trough

Find Peak and Trough

You are given a sequence of stock prices. Your task is to determine the peak (maximum price) and the trough (minimum price) from the list. In mathematical terms, if (prices) is the array of stock prices, then you need to compute (\text{peak} = \max(prices)) and (\text{trough} = \min(prices)).

The input will be provided via standard input (stdin) and the output should be printed to standard output (stdout). Please ensure that your solution can handle various sizes of input efficiently.

inputFormat

The first line contains an integer (n) representing the number of stock prices. The second line contains (n) space-separated integers representing the historical stock prices.

outputFormat

Output two space-separated integers where the first integer is the peak (largest value) and the second integer is the trough (smallest value) among the given prices.## sample

8
10 7 8 9 6 12 4 11
12 4

</p>