Problem list
Log in
#coci00383 · COCI 2015/2016 Contest 5

Perica

Gold III 1.0 s 64 MB
  • “I’m stopping by Žnidaršić’s house, you play the piano, Perica.”
  • ”Ok, dad, I will!” And so, Perica began playing the piano. His piano consists of $N$ keys. Each key has a value written on it, $a_{i}$. When Perica plays the piano, he presses exactly $K$ different keys at the same time. The piano is a bit strange because, after pressing $K$ keys at the same time, it will play only the key with the largest value. Perica is going to play each combination of $K$ keys on the piano and he wants to know the sum of values of the keys that will be played. Help Perica determine the remainder of that number modulo 1 000 000 007.

Input

The first line of input contains two integers $N$ and $K$ (1 ⩽$N$ ⩽100 000, 1 ⩽$K$ ⩽50). The following line of input contains $N$ integers $a_{i}$ (0 ⩽$a_{ij}$ ⩽$10^{9}$).

Output

The first and only line of output must contain the required number from the task.

Constraints

In test cases worth 40% of total points, it will additionally hold 1 ⩽$N$ ⩽1000.

Example 1

Input
5 3
2 4 2 3 4
5 1
1 0 1 1 1
5 2
3 3 4 0 0
Output
output
output
39
4
31
Pojašnjenje prvog primjera: All selections of K keys are: [2, 4, 2], [2, 4, 3], [2, 4, 4], [2, 2, 3], [2, 2, 4], [2, 3,
4], [4, 2, 3], [4, 2, 4], [4, 3, 4], [2, 3, 4].
Source
COCI 2015/2016 Contest 5
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code