AmazonOA #363
Count Spikes
估计困难可在线判题
prices[i] is called a k-Spike if at least k elements to its left are strictly less than prices[i], and at least k elements to its right are strictly less as well. Given the array prices and an integer k, count the number of k-Spike elements.
输入格式
The first line contains n and k; the second line contains n integers prices[i]. Constraints: 1≤n≤100000, 1≤k≤n, 1≤prices[i]≤1000000000.
输出格式
Output the number of k-Spike elements.
样例 1
输入:
6 2
1 2 8 5 3 4
输出:
2
样例 2
输入:
5 1
1 2 2 1 2
输出:
2
样例 3
输入:
5 1
7 7 7 7 7
输出:
0
样例说明
The answer for the example is 2: the values 8 and 5 both satisfy the condition.