#P1616D. Keep the Average High
Keep the Average High
No submission language available for this problem.
Description
You are given an array of integers and an integer .
You need to select the maximum number of elements in the array, such that for every subsegment containing strictly more than one element , either:
- At least one element on this subsegment is not selected, or
- .
The first line of input contains one integer (): the number of test cases.
The descriptions of test cases follow, three lines per test case.
In the first line you are given one integer (): the number of integers in the array.
The second line contains integers ().
The third line contains one integer ().
For each test case, print one integer: the maximum number of elements that you can select.
Input
The first line of input contains one integer (): the number of test cases.
The descriptions of test cases follow, three lines per test case.
In the first line you are given one integer (): the number of integers in the array.
The second line contains integers ().
The third line contains one integer ().
Output
For each test case, print one integer: the maximum number of elements that you can select.
Samples
Note
In the first example, one valid way to select the elements is . All subsegments satisfy at least one of the criteria. For example, for the subsegment , we have that the element is not selected, satisfying the first criterion. For the subsegment , we have , satisfying the second criterion.
We can't select all elements, because in this case for , all elements are selected and we have . Thus, the maximum number of selected elements is .
In the second example, one valid solution is .
In the third example, one valid solution is .
In the fourth example, one valid solution is .