#C8743. Buildings Receiving Sunlight

    ID: 52759 Type: Default 1000ms 256MiB

Buildings Receiving Sunlight

Buildings Receiving Sunlight

Given a sequence of building heights, determine how many buildings will receive sunlight. A building receives sunlight if it is taller than every building to its left. Formally, for a sequence of heights \(h_1, h_2, \dots, h_n\), the \(i^{th}\) building receives sunlight if \(h_i > \max\{h_1, h_2, \dots, h_{i-1}\}\) (with the convention that the maximum of an empty set is \(-\infty\)).

For example, given the sequence [3, 2, 4, 6, 5, 1], the buildings receiving sunlight are 3, 4, and 6, so the output is 3.

inputFormat

The input is given as two lines from standard input. 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.

outputFormat

Output a single integer representing the number of buildings that receive sunlight.## sample

6
3 2 4 6 5 1
3