Distinct Increasing Subsequences of Length K
Time limit2sMemory limit512 MB
Count the distinct value sequences of length K that appear as increasing subsequences of the given array, modulo 5000000.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Sorting, Combinatorics
- Solved
- No attempts yet
Problem
You are given a sequence of length and an integer . Count the subsequences of that have length and are increasing. Two subsequences with the same sequence of values count as one, even when they are taken from different positions.
A subsequence is what remains after deleting zero or more elements of and keeping the order of the rest. A subsequence of length is increasing when holds for every with .
Input
The first line contains the size of the sequence and the integer . (, , )
The second line contains , separated by spaces. ()
Output
Print, on one line, the number of distinct increasing subsequences of length modulo .