-->
当前位置:首页 > Eng

编程题:Segment Tree

Luz3年前 (2022-11-26)Eng667
Today HH is learning a new data structure named segment tree, which is often used to solve segment problem, here comes one:
Give you an unordered sequence of length n,(a$_1$,a$_2$,…,a$_n$), now you are supposed to calculate how many segment **[L,R]**(1≤L≤R) are there satisfies two conditions :
1.the length of the segment is k(i.e. R−L+1=k).
2.the number between L and R(both including) appears at least q times in total.
HH thinks the problem is too easy so he gives the problem to you.
Additional remarks:
In the following example , we can find 4 segments:
[1,3],1 appears 0 time,2 appears 2 times,3 appears 1 time,so 3 times in total.
[2,4],4 times in total.[3,5] 3 times in total.[4,6],2 times in total.
In the second example, we can find:
[1,3],[2,4],[3,5].
In the third example, we can't find any.



### Input:
The first line contains an positive integer T(1≤T≤10), represents there are T test cases.
For each test case: The first line contains three positive integers n,k,q(1≤n≤100,1≤k≤100,1≤q≤100),the length of the sequence , the length of the segment [l,R], and the times required to appear. The second line contains n integers a$_1$,a$_2$…a$_n$(1≤a$_i$≤100) - the sequence.



### Output:


For each test case, output one line an integer : the number of segment satisfies both conditions.



### Sample Input:



in
3
5 3 2
2 3 2 4 5
5 3 3
2 3 2 4 5
5 3 6
2 3 2 4 5


### Sample Output:



out
4
3
0







answer:若无答案欢迎评论