#K48947. Buildings with Sunrise View

    ID: 28533 Type: Default 1000ms 256MiB

Buildings with Sunrise View

Buildings with Sunrise View

Given a sequence of integers representing building heights arranged from east to west, determine the number of buildings that have an unobstructed view of the sunrise. A building has a clear view if every building to its left is strictly shorter. In other words, for a building at index \(i\) to see the sunrise, all buildings at indices less than \(i\) must have heights less than that building. If there are no buildings (i.e. \(n = 0\)), then the answer is \(0\).

Formally, given an array \(H = [h_1, h_2, \dots, h_n]\), compute the number of indices \(i\) such that:

\[ h_i > \max_{1 \leq j < i} h_j \]

(For \(i = 1\), the building always sees the sunrise.)

inputFormat

The first line contains an integer \(n\), 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 — the number of buildings that have a clear view of the sunrise.

## sample
5
7 1 8 4 9
3