#C1339. Count Unobstructed West Views
Count Unobstructed West Views
Count Unobstructed West Views
You are given a sequence of building heights from west to east. A building has an unobstructed view to the west if it is taller than every building before it. Formally, for a sequence of heights \(h_1, h_2, \ldots, h_n\), the i-th building has an unobstructed view if
for \(i \ge 1\) (with the convention that the maximum of an empty set is \(-\infty\)). Your task is to compute the total number of buildings that have an unobstructed view.
inputFormat
The first line contains an integer \(n\) representing the number of buildings. The second line contains \(n\) space-separated integers, where the \(i\)-th integer represents the height of the \(i\)-th building.
outputFormat
Output a single integer — the number of buildings that have an unobstructed view to the west.
## sample6
3 7 8 3 6 1
3