#C7472. Maximum Number of Pools

    ID: 51347 Type: Default 1000ms 256MiB

Maximum Number of Pools

Maximum Number of Pools

You are given a row of buildings where each building has a specific height. A pool of water can be formed over any contiguous segment of buildings if and only if every building in that segment has a height less than or equal to a given threshold (h). In other words, a pool is created by a maximal contiguous block of buildings with heights (\le h). Your task is to determine the maximum number of pools that can be formed.

For example, consider 7 buildings with heights [1, 2, 6, 5, 3, 4, 7] and a threshold (h = 5). The eligible segments are [1,2] and [5,3,4] which count as 2 pools.

inputFormat

The input consists of two lines:
- The first line contains two space-separated integers (N) and (h), where (N) is the number of buildings and (h) is the height threshold.
- The second line contains (N) space-separated integers representing the heights of the buildings.

outputFormat

Output a single integer representing the maximum number of pools of water that can be formed.## sample

7 5
1 2 6 5 3 4 7
2