#C14263. Sunny Buildings Count
Sunny Buildings Count
Sunny Buildings Count
You are given a row of buildings represented by their heights. In the evening, the sun sets from the right-hand side. A building is said to receive direct sunlight if it is strictly taller than all the buildings to its right.
Formally, given an array of heights \(h_0, h_1, \ldots, h_{n-1}\), the \(i\)-th building receives direct sunlight if
\(h_i > \max\{h_{i+1}, h_{i+2}, \ldots, h_{n-1}\}\)
Your task is to calculate the number of buildings that will receive direct sunlight.
inputFormat
The input is given in the following format in stdin:
n h1 h2 h3 ... hn
Here, n
is the number of buildings. The following line contains n
space-separated integers where each integer represents the height of a building.
outputFormat
Output a single integer to stdout representing the number of buildings that receive direct sunlight.
## sample6
3 7 8 3 6 1
3