#K56937. Sunlight Buildings
Sunlight Buildings
Sunlight Buildings
Given \( n \) consecutive buildings with positive heights, determine how many of them can receive direct sunlight. A building can receive sunlight if and only if its height is strictly greater than all the buildings to its left. This problem simulates the scenario where the sun shines from the left side, illuminating only those buildings that are not shadowed by any previous taller building.
For example, consider the building heights [7, 4, 8, 2, 9]. The buildings that receive sunlight are 7, 8, and 9, totaling 3 buildings.
inputFormat
The input is given via stdin and consists of two lines. The first line contains an integer ( n ), representing the number of buildings. The second line contains ( n ) space-separated positive integers indicating the heights of the buildings in order.
outputFormat
Output a single integer to stdout that represents the number of buildings which can receive direct sunlight.## sample
5
7 4 8 2 9
3
</p>