#C3928. Find Maximum and Minimum of an Array

    ID: 47409 Type: Default 1000ms 256MiB

Find Maximum and Minimum of an Array

Find Maximum and Minimum of an Array

Given an array \(A\) of \(N\) integers, your task is to determine the maximum and minimum elements present in the array. You should output the maximum element first, followed by the minimum element, separated by a single space.

Input Format:

  • The first line contains an integer \(N\) representing the number of elements in the array.
  • The second line contains \(N\) space-separated integers representing the elements of the array.

Output Format:

  • Output two integers separated by a space: the maximum element and the minimum element in the array.

Example:

Input:
6
3 1 4 1 5 9

Output:
9 1

inputFormat

The first line of input contains a single integer (N) denoting the number of elements in the array. The second line contains (N) space-separated integers representing the array elements.

outputFormat

Output two integers: the maximum and minimum values in the array, separated by a space.## sample

6
3 1 4 1 5 9
9 1