#K53567. Buildings with Direct Sunlight
Buildings with Direct Sunlight
Buildings with Direct Sunlight
Given the heights of a row of buildings, determine the number of buildings that have a direct view of the sunset. A building is considered to have a direct view if it is taller than every building to its right. Note that the rightmost building always has a view, even if its height is not unique.
The problem can be formalized as follows: given an array of non-negative integers \(h_1, h_2, \ldots, h_n\) where \(h_i\) represents the height of the \(i\)-th building, count the number of indices \(i\) such that for all \(j > i\), \(h_i > h_j\).
You are required to read the input from standard input (stdin) and output the result to standard output (stdout).
inputFormat
The first line contains an integer \(n\), representing the number of buildings.
The second line contains \(n\) space-separated integers which represent the heights of the buildings.
outputFormat
Print a single integer representing the number of buildings that have a direct view of the sunset.
## sample6
3 7 8 3 6 1
3
</p>