#C4443. Counting Buildings Receiving Sunlight
Counting Buildings Receiving Sunlight
Counting Buildings Receiving Sunlight
In this problem, you are given a sequence of n buildings each with a specific height. The sunlight comes from the left side. A building will receive direct sunlight if it is strictly taller than all the buildings to its left. Note that the very first building always receives sunlight.
Formally, given a sequence of building heights \(h_1, h_2, \ldots, h_n\), a building \(h_i\) (for \(i \ge 1\)) receives sunlight if \(h_i > \max\{h_1, h_2, \ldots, h_{i-1}\}\). Your task is to count how many buildings receive sunlight.
inputFormat
The first line of input contains an integer n
, representing the number of buildings.
The second line contains n
space-separated integers representing the heights of the buildings.
outputFormat
Output a single integer that denotes the number of buildings which receive direct sunlight from the left.
## sample6
3 1 4 2 5 7
4