#K68282. Taco: Count Visible Buildings
Taco: Count Visible Buildings
Taco: Count Visible Buildings
You are given a sequence of integers representing the heights of buildings arranged in a line. An observer is located at the beginning of the line and can see a building if and only if no building taller than it exists between the observer and that building. In other words, a building at index \(i\) is visible if \(h_i > \max\{h_1, h_2, \dots, h_{i-1}\}\). Notably, the first building is always visible.
Your task is to compute the total number of buildings visible to the observer.
inputFormat
The input is read from standard input (stdin). 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 to standard output (stdout) a single integer: the total number of buildings visible to the observer.
## sample8
1 3 2 4 5 3 2 1
4
</p>