#GYM104665C. Hatter's Party
Hatter's Party
Description
Mr. Hatter has $N$ strands of noodles, and wants to prepare some number of noodle dishes for his lunch party. The $i^{th}$ strand has flavor level $f_i$.
Each dish must have at least $K$ strands of noodles. The flavor of a dish is the maximum flavor value out of the noodle strands in the dish.
Mr. Hatter wants to know what is the maximum sum of flavors across all dishes he can prepare, assuming he prepares the dishes optimally?
The first line of input contains $N, K$, the total number of noodle strands and the number of strands of noodles required to make a dish. $(1 \leq N \leq 10^5$ and $1 \leq K \leq N)$
The next $N$ lines each contain $f_i$, the flavor value of the $i^{th}$ noodle strand. $(0 \leq f_i \leq 10^9)$
Please output $1$ integer, the maximum sum of flavors across all dishes Mr. Hatter can prepare.
Input
The first line of input contains $N, K$, the total number of noodle strands and the number of strands of noodles required to make a dish. $(1 \leq N \leq 10^5$ and $1 \leq K \leq N)$
The next $N$ lines each contain $f_i$, the flavor value of the $i^{th}$ noodle strand. $(0 \leq f_i \leq 10^9)$
Output
Please output $1$ integer, the maximum sum of flavors across all dishes Mr. Hatter can prepare.
2 1
76
100
4 2
1
5
3
1
9 3
10
9
9
9
9
1
1
1
1
176
8
28