#C10408. Median of an Odd-Length Array

    ID: 39610 Type: Default 1000ms 256MiB

Median of an Odd-Length Array

Median of an Odd-Length Array

You are given an integer N and an array of N non-negative integers, where N is always odd. Your task is to find the median of the array. The median is defined as the middle element after the array is sorted. Formally, if the sorted array is \(a_0, a_1, \ldots, a_{N-1}\), then the median is \(a_{\lfloor N/2 \rfloor}\).

Example:

  • Input: N = 5 and array = [1, 3, 3, 6, 7] → Sorted array = [1, 3, 3, 6, 7], median = 3.

Note: The input is provided via stdin and the answer should be printed to stdout.

inputFormat

The input consists of two lines. The first line contains an odd integer N, which is the number of elements in the array. The second line contains N space-separated non-negative integers.

outputFormat

Output a single integer which is the median of the array.## sample

5
1 3 3 6 7
3

</p>