#K49847. Count Strictly Increasing Subsequences
Count Strictly Increasing Subsequences
Count Strictly Increasing Subsequences
Given an array of integers and an integer L, your task is to determine the number of strictly increasing subsequences of length exactly L. A subsequence is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements.
Note that the subsequences are not required to be contiguous. Use efficient techniques to count the valid subsequences.
For example, given the array [1, 2, 3, 4] and L = 2, there are 6 strictly increasing subsequences: [1,2], [1,3], [1,4], [2,3], [2,4] and [3,4].
inputFormat
The first line of input contains an integer T, representing the number of test cases. For each test case, the first line contains two space-separated integers N and L, where N is the number of elements in the array and L is the required length of the increasing subsequence to count. The second line contains N space-separated integers.
Formally, the input format is:
$$T$$
For each test case:
$$N\ L$$
$$a_1\ a_2\ \dots \ a_N$$
outputFormat
For each test case, output a single integer on a new line representing the number of strictly increasing subsequences of length exactly L.## sample
3
4 2
1 2 3 4
5 3
5 3 4 2 1
6 4
1 3 2 4 3 5
6
0
3
</p>