Count of Increasing Subsequences
InterviewTime limit1sMemory limit512 MB
Count the strictly increasing subsequences of length K in a sequence of N distinct values, reported modulo 1e9+7.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Binary search, Prefix sum, Array
- Solved
- No attempts yet
Problem
Given a sequence A of size N and an integer K, count the increasing subsequences of A whose length is K.
Input
The first line contains N and K. The second line contains the sequence A1, A2, ..., AN.
Output
On the first line, print the number of increasing subsequences of A whose length is K, modulo 109+7.
Constraints
- 1 ≤ N ≤ 100,000
- 1 ≤ K ≤ 10
- 1 ≤ Ai ≤ N
- All Ai are distinct.