Problem H: Kth Longest Length

Problem H: Kth Longest Length

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 145  Solved: 22
[Submit][Status][Web Board]


Giving you three integers: n, m, k and a sequence {an}. The elements in {an} are distinct. Please find the longest continuous subsequence whose kth smallest element is as large as possible. And the subsequence’s length is larger than or equal to m. Please print the length of the subsequence.


The first line is an integer T, which is the number of test cases. (1 <= T <= 10)

Each test case begins with three integers, n, m and k. (1 <= n <= 300000, 1 <= k <= m <= n)

Then n integers represent the elements in {an}. (1 <= ai <= 107)


An integer for each test case, the length problem required.

Sample Input

5 3 2
1 5 3 2 4

Sample Output



Bonus problem