#C10726. Count Sunset Buildings
Count Sunset Buildings
Count Sunset Buildings
Given a sequence of building heights, determine how many buildings can see the sunset. A building can see the sunset if it is strictly taller than every building to its left. In other words, the (i)-th building can see the sunset if (h_i > \max{h_1, h_2, \dots, h_{i-1}}) where (h_i) represents its height. Read the input from standard input and write the result to standard output.
inputFormat
The first line contains an integer (n), the number of buildings. The second line contains (n) space-separated integers (h_1, h_2, \dots, h_n) representing the heights of the buildings. When (n = 0), the second line will be empty.
outputFormat
Output a single integer representing the number of buildings that can see the sunset.## sample
5
7 4 8 2 9
3