CF1692G.2^Sort
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given an array a of length n and an integer k , find the number of indices 1≤i≤n−k such that the subarray [ai,…,ai+k] with length k+1 (not with length k ) has the following property:
- If you multiply the first element by 20 , the second element by 21 , ..., and the ( k+1 )-st element by 2k , then this subarray is sorted in strictly increasing order.
More formally, count the number of indices 1≤i≤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≤t≤1000 ) — the number of test cases.
The first line of each test case contains two integers n , k ( 3≤n≤2⋅105 , 1≤k<n ) — the length of the array and the number of inequalities.
The second line of each test case contains n integers a1,a2,…,an ( 1≤ai≤109 ) — the elements of the array.
The sum of n across all test cases does not exceed 2⋅105 .
输出格式
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
说明/提示
In the first test case, both subarrays satisfy the condition:
- i=1 : the subarray [a1,a2,a3]=[20,22,19] , and 1⋅20<2⋅22<4⋅19 .
- i=2 : the subarray [a2,a3,a4]=[22,19,84] , and 1⋅22<2⋅19<4⋅84 .
In the second test case, three subarrays satisfy the condition: - i=1 : the subarray [a1,a2]=[9,5] , and 1⋅9<2⋅5 .
- i=2 : the subarray [a2,a3]=[5,3] , and 1⋅5<2⋅3 .
- i=3 : the subarray [a3,a4]=[3,2] , and 1⋅3<2⋅2 .
- i=4 : the subarray [a4,a5]=[2,1] , but 1⋅2=2⋅1 , so this subarray doesn't satisfy the condition.