#K88867. Maximum Visible Buildings

    ID: 37404 Type: Default 1000ms 256MiB

Maximum Visible Buildings

Maximum Visible Buildings

You are given an integer N representing the number of buildings in a row and a list of N integers representing the heights of the buildings. The first building is always visible. For each subsequent building, it is visible if its height is strictly greater than the maximum height among all previous buildings. Formally, a building at index i (0-indexed) is visible if
$$\text{heights}[i] > \max(\text{heights}[0], \text{heights}[1], \dots, \text{heights}[i-1])$$

Your task is to compute the maximum number of buildings that are visible when viewed from the left (starting at the first building).

inputFormat

The input is read from stdin and 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 is the height of a building.

outputFormat

Output a single integer to stdout representing the maximum number of buildings that can be seen from the left.

## sample
6
1 2 3 4 5 6
6

</p>