#K45707. Max Total Sweetness
Max Total Sweetness
Max Total Sweetness
You are given n fruits each with a sweetness value. Your task is to select exactly k fruits such that the total sweetness is maximized. In other words, if the sweetness values are given by \(a_1, a_2, \ldots, a_n\), you need to choose a subset of exactly k fruits so that the sum \(\sum_{i=1}^{k} a_{\pi(i)}\) is as large as possible, where \(a_{\pi(1)} \geq a_{\pi(2)} \geq \ldots \geq a_{\pi(n)}\).
inputFormat
The first line of input contains two integers n and k separated by a space.
The second line contains n integers representing the sweetness values.
outputFormat
Output a single integer which is the maximum total sweetness achievable by selecting exactly k fruits.
## sample5 3
2 5 3 8 6
19