#K77382. Counting Increasing Subarrays

    ID: 34852 Type: Default 1000ms 256MiB

Counting Increasing Subarrays

Counting Increasing Subarrays

You are given an array of integers and an integer d. Your task is to determine the number of contiguous subarrays (of length d) that are strictly increasing. A subarray is considered strictly increasing if every element is less than the element immediately following it.

For example, if the array is [1, 3, 5, 4, 2, 7, 8, 9] and d is 3, the subarrays [1, 3, 5], [2, 7, 8], and [7, 8, 9] are strictly increasing, so the answer is 3.

The problem can be formulated mathematically as follows:

[ \text{Count} = \sum_{i=1}^{n-d+1} I\left( a_i < a_{i+1} < \dots < a_{i+d-1} \right) ]

where \( I(\cdot) \) is the indicator function that returns 1 if the condition is true and 0 otherwise.

Your program should read from standard input and output the result to standard output.

inputFormat

The first line of input contains two integers n and d separated by a space, where n is the number of elements in the array and d is the length of the subarray to consider. The second line contains n integers separated by spaces representing the array.

outputFormat

Output a single integer representing the number of strictly increasing contiguous subarrays of length d.

## sample
8 3
1 3 5 4 2 7 8 9
3