| title | Rassim Sort |
|---|---|
| author | Redhouane Abdellah |
| difficulty | Medium |
Rassim is bored out of his mind, he wants to play a game with his best friend Adnane; Adnane, being nice and wholesome, comes up with a fun challenge involving arrays.
The rules are simple, Rassim has an array
If Rassim fails to complete the challenge before Adnane finished eating all of the pizza from the canteen, Adnane will bully his friends and destroy all of Wissal's stuffed animals, so he needs your help to find a fast algorithmic solution to this challenge.
Task: Determine the number of indices that satisfy the condition.
The first line of input contains two integers
The second line of input contains
Output a single integer, the number of indices satisfying the condition.
$3 \le n \le 2 \cdot 10^5$ $1 \le k < n$ - Time limit: 1.0 seconds
- Memory limit: 256 MB
4 2
1 10 100 1000
2
Both subarrays satisfy the condition:
-
$i = 1$ : the subarray$[a_1,a_2,a_3] = [1, 10, 100]$ , and$2^0 \cdot 1 < 2^1 \cdot 10 < 2^2 \cdot 100$ . -
$i = 2$ : the subarray$[a_2,a_3,a_4] = [10,100,1000]$ and$2^0 \cdot 10 < 2^1 \cdot 100 < 2^2 \cdot 1000$ .
9 3
3 9 12 3 9 12 3 9 12
0