#K8406. Buildings and Sunlight
Buildings and Sunlight
Buildings and Sunlight
You are given an integer N representing the number of buildings in a row, followed by a list of N integers where each integer Ai denotes the height of the i-th building. The problem is to determine how many buildings receive direct sunlight.
The first building always receives sunlight. For each subsequent building, it receives direct sunlight if its height is strictly greater than all the buildings to its left. In mathematical terms, the i-th building is illuminated if:
\(A_i > \max\{A_1, A_2, \ldots, A_{i-1}\}\)
Your task is to calculate and output the number of buildings that receive direct sunlight.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains a single integer N (where \(0 \leq N \leq 10^5\)).
- The second line contains N space-separated integers representing the heights of the buildings.
outputFormat
Output a single integer to stdout, which is the number of buildings that receive direct sunlight.
## sample6
3 7 8 3 6 1
3
</p>