#C13110. Median Finder

    ID: 42613 Type: Default 1000ms 256MiB

Median Finder

Median Finder

You are given a list of integers. Your task is to find the median value of the list. The median is defined as follows:

  • If the list is empty, output "None".
  • If the list has an odd number of elements, the median is the middle element after sorting the list in non-decreasing order.
  • If the list has an even number of elements, the medians are the two middle elements after sorting the list; output both values separated by a space.

In mathematical terms, let \( n \) be the number of elements, and let \( a_1, a_2, \ldots, a_n \) be the sorted order. If \( n = 0 \), output \( \text{None} \). If \( n \) is odd, output \( a_{\frac{n+1}{2}} \). If \( n \) is even, output \( a_{\frac{n}{2}} \) and \( a_{\frac{n}{2}+1} \) (in that order) separated by a single space.

inputFormat

The first line contains an integer \( n \) indicating the number of elements. If \( n > 0 \), the second line contains \( n \) space-separated integers. If \( n = 0 \), the list is empty.

outputFormat

If the list is empty, output None. Otherwise, output the median value if the list has odd length, or output the two median values separated by a single space if the list has even length.

## sample
0
None