题库练习 2^Sort
← 上一题 下一题 →

A15081 | 2^Sort

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Given an array $a$ of length $n$ and an integer $k$ , find the number of indices $1 \leq i \leq n - k$ such that the subarray $[a_i, \dots, a_{i+k}]$ with length $k+1$ (not with length $k$ ) has the following property:

- If you multiply the first element by $2^0$ , the second element by $2^1$ , ..., and the ( $k+1$ )-st element by $2^k$ , then this subarray is sorted in strictly increasing order.

More formally, count the number of indices $1 \leq i \leq n - k$ such that $$$$2^0 \cdot a_i < 2^1 \cdot a_{i+1} < 2^2 \cdot a_{i+2} < \dots < 2^k \cdot a_{i+k}. $$$$

输入格式

The first line contains an integer $t$ ( $1 \leq t \leq 1000$ ) — the number of test cases.

The first line of each test case contains two integers $n$ , $k$ ( $3 \leq n \leq 2 \cdot 10^5$ , $1 \leq k < n$ ) — the length of the array and the number of inequalities.

The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \leq a_i \leq 10^9$ ) — the elements of the array.

The sum of $n$ across all test cases does not exceed $2 \cdot 10^5$ .

输出格式

For each test case, output a single integer — the number of indices satisfying the condition in the statement.

输入输出样例

输入 #1
6
4 2
20 22 19 84
5 1
9 5 3 2 1
5 2
9 5 3 2 1
7 2
22 12 16 4 3 22 12
7 3
22 12 16 4 3 22 12
9 3
3 9 12 3 9 12 3 9 12
输出 #1
2
3
2
3
1
0
C++ 编辑器
输入
输出