An Amazon hiring team is forming a final interview panel from
The score of candidate
The team must choose exactly
Among all possible choices of
Your task is to print the maximum possible median and the minimum possible total score among all choices that achieve this median.
The median of
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of candidates and the number of candidates to choose.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the candidate scores.
Print two integers — the maximum possible median and the minimum possible total score among all choices of KaTeX can only parse string typed expression candidates that achieve this median.
Input
6 3
8 1 5 2 9 4Output8 18ExplanationFor KaTeX can only parse string typed expression, the median position is KaTeX can only parse string typed expression.
The maximum possible median is KaTeX can only parse string typed expression. To achieve this, one optimal choice is KaTeX can only parse string typed expression. After sorting, it becomes KaTeX can only parse string typed expression, whose median is KaTeX can only parse string typed expression. The total score is KaTeX can only parse string typed expression, which is minimum among all choices with median KaTeX can only parse string typed expression.
Example 2:
Input
5 4
7 2 9 1 8Output7 25ExplanationFor KaTeX can only parse string typed expression, the median position is KaTeX can only parse string typed expression.
The maximum possible median is KaTeX can only parse string typed expression. Choose KaTeX can only parse string typed expression. After sorting, the median is KaTeX can only parse string typed expression, so this choice is not valid for median KaTeX can only parse string typed expression.
A valid minimum-sum choice is KaTeX can only parse string typed expression. After sorting, it becomes KaTeX can only parse string typed expression, whose median is KaTeX can only parse string typed expression. The total score is KaTeX can only parse string typed expression.
Example 3:
Input
5 1
10 3 8 1 6Output10 10ExplanationWhen KaTeX can only parse string typed expression, the median is the only chosen element. To maximize the median, choose KaTeX can only parse string typed expression. The minimum total score is also KaTeX can only parse string typed expression.