report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Value of subsequences - MarisaOJ: Marisa Online Judge

Value of subsequences

Time limit: 1000 ms
Memory limit: 256 MB
The value of an array $B$ is the maximum element in $B$. Given an array $A$ of $n$ integers. Find the sum of value of all subsequences of length $k$ of $A$. ### Input - The first line contains 2 integers $n, k$. - The second line contains $n$ integers $A_i$. ### Output - Print the sum, modulo $10^9+7$. ### Constraints - $1 \le k \le n \le 10^5$. ### Example Input: ``` 4 2 6 7 6 5 ``` Output: ``` 39 ```
Introduction to combinatorics
Binomial coefficient
Fork and knife
Binomial coefficient 2
Equation
Array rearrangement
Value of subsequences
Inequation
Growing mushrooms
Binary matrix
Broken board
Triangles counting
Minecraft graph
Restricted path
Heavenly Peach Garden
Topic
Sorting
Math
Combinatorics
Rating 1400
Solution (1) Solution