The Land of Mines (MEDIUM)

3.4

5 votes
Medium
Problem

As our mighty hero Sin is in pursuit of the wicked wizard,what he faces ahead is the land of mines .
In order to cross the land of mines Sin needs to disarm all the mines in his path.Individual mine contained an array of integers and a separate individual integer k written on it and a space above which "key" is written.
In order to diffuse a mine Sin needs to find key.The key to diffuse the bomb resides in the array written on individual mines.
To diffuse a mine Sin needs to find the count of all the sub arrays which contains k or more than k similar elements.
Since Sin is weak at calculations help Sin calculate the key in order to diffuse individual mine.

Contraints
1<=t<=1000
1<=n<=105
1<=ai<=109
1<=k<=105


Input
First line contains integer t denoting number of testcases , Next t testcases contains :
FIrst line contains integer n (size of array ) and k
Second line contains array of integers.

Output
for every testcase , output no. of subarrays.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For test case 2 : the sub arrays are: {4,3,4},{4,3,4,3},{3,4,3}

Editor Image

?