#C10376. Great Rooftop Restaurants
Great Rooftop Restaurants
Great Rooftop Restaurants
In a city with many buildings, a rooftop restaurant is considered great if it offers an unobstructed view of the sunset. Formally, suppose the building heights are given by \(a_1, a_2, \dots, a_n\). A building \(a_i\) is a great rooftop restaurant if
\(a_i > \max\{a_{i+1}, a_{i+2}, \dots, a_n\}\)
Note that the rightmost building (i.e. \(a_n\)) is always counted since there are no buildings to its right. Given the number of buildings and their respective heights, your task is to count how many great rooftop restaurants exist.
inputFormat
The input is read from stdin and has the following format:
- The first line contains a single integer \(n\), the number of buildings.
- The second line contains \(n\) space-separated integers representing the heights of the buildings.
outputFormat
Output a single integer to stdout representing the number of great rooftop restaurants.
## sample5
3 7 8 3 6
2