#C6592. Count Visible Steps in a City Skyline

    ID: 50369 Type: Default 1000ms 256MiB

Count Visible Steps in a City Skyline

Count Visible Steps in a City Skyline

You are given a sequence of non-negative integers representing the heights of buildings in a city. A building is considered a visible step if its height is strictly greater than all the buildings to its left. In mathematical terms, if we denote the building heights as \(h_1, h_2, \dots, h_n\), then a building \(h_i\) (with \(i \ge 1\)) is visible if \(h_i > \max\{h_1, h_2, \dots, h_{i-1}\}\). The first building is always visible as there are no buildings to its left.

Your task is to count the number of visible steps (buildings) from the given list.

Example:

Input: 6
       3 1 4 1 5 9
Output: 4

inputFormat

The input is given in two lines:

  • The first line contains a single integer \(n\) which represents the number of buildings.
  • The second line contains \(n\) space-separated integers representing the heights of the buildings.

If \(n = 0\), the second line may be empty.

outputFormat

Output a single integer representing the number of visible steps in the city skyline.

## sample
6
3 1 4 1 5 9
4

</p>