#P17153. [ICPC 2017 Xi'an R] Arrangement for Contests

    ID: 19431 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>贪心2017线段树分块ICPC西安

[ICPC 2017 Xi'an R] Arrangement for Contests

Problem Description

As a sponsor of programming contests, Yu has many factors to consider. Recently, he has found that the difficulties of problems can be a serious factor.

For novices, they may simply ignore the problems that are too hard; and for experts in programming contests, an easy problem almost means nothing. Moreover, if a contest consists of both easy and hard questions, it will not satisfy them – but make them unhappy for both reasons.

Therefore, Yu has come up with an idea: holding different kinds of contests! Novices tend to participate in a contest known as an easy one, but will not join a hard one.

In details, suppose the difficulty of a problem can be measured as a positive integer ii. The bigger number means that the problem is harder. In Yu’s design, a contest consists of several problems with consistent difficulties. Formally, if a contest has kk problems, then their difficulties must be i,i+1,,i+k1i, i+1, \dots, i+k-1. This is because if there are two problems with same difficulties, their functions in the contest will be the same, which is not good; and if two problems have a big gap in difficulties, there will be questions that are mentioned above. Now, a contest with difficulty 1,2,3,4,51, 2, 3, 4, 5 is obviously a simple one, and a contest with 5,6,7,8,95, 6, 7, 8, 9 can be a hard one.

Yu has a large amount of problems, and he measures all the difficulties. Now, he wants to hold as many contests as possible. Do you know how many contests can he hold?

Input Format

In the first line there is an integer TT (1T10)(1 \le T \le 10), showing that there are TT test cases. Each test case consists of two lines.

For each test case, in the first line are two integers N,KN, K (1KN100,000)(1 \le K \le N \le 100, 000), where NN means the kinds of difficulties, and KK is the number of questions that a contest may have. In the second line, there are NN numbers a[i]a[i] (0a[i]109)(0 \le a[i] \le 10^9), the ii-th indicates the number of questions with difficulty ii.

Output Format

For each test case, the output should be an integer, indicating the maximum number of contests that Yu can hold.

3
3 2
1 2 1
6 3
1 5 3 4 7 6
9 4
2 7 1 3 6 5 8 9 4
2
5
6