#C1254. Sunlit Buildings

    ID: 41978 Type: Default 1000ms 256MiB

Sunlit Buildings

Sunlit Buildings

You are given a street with a row of buildings. The heights of the buildings are provided in an array of integers. A ray of sunlight comes from the left side and travels to the right. A building is considered to receive sunlight if it is not blocked by any building to its left that is taller or equal in height. In other words, a building will receive sunlight if its height is at least as high as every building to its left.

Your task is to determine the number of buildings that receive sunlight.

The mathematical formulation is as follows:

Let \(H = [h_1, h_2, \ldots, h_n]\) be the list of building heights. A building \(h_i\) receives sunlight if and only if \(h_i \geq \max\{h_1, h_2, \ldots, h_{i-1}\}\). By convention, the first building always receives sunlight.

inputFormat

The input consists of two lines.

  • The first line contains a single integer \(n\) representing the number of buildings.
  • The second line contains \(n\) space-separated integers, where each integer represents the height of a building.

outputFormat

Output a single integer representing the count of buildings that receive sunlight.

## sample
6
3 5 4 9 2 8
3