#C2627. Taco - Median and Mode
Taco - Median and Mode
Taco - Median and Mode
You are given a list of integers. Your task is to compute the (median) and (mode) of the list. The (median) is defined as the middle element of the sorted list if the number of elements is odd, or the average of the two middle elements if the number is even. The (mode) is the value that appears most frequently; if there is a tie, choose the smallest such number.
For example, given the list: 1 3 3 6 7 8 9, the median is 6.0 (since the middle value is 6) and the mode is 3 (as 3 appears most frequently).
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains an integer (n), the number of elements. The second line contains (n) space-separated integers.
outputFormat
Print the median and the mode in one line to standard output (stdout). The median should be printed as a float with one decimal, followed by a space and then the mode.## sample
1
5
5.0 5