#C1939. Counting Visible Trees
Counting Visible Trees
Counting Visible Trees
You are given a sequence of n trees in a forest, where each tree has a certain height. A tree is considered visible if there is no tree before it (to its left) that is taller or of equal height. In other words, the ith tree is visible if for every j (1 ≤ j < i), the height of tree j is strictly less than the height of tree i.
Mathematically, let \( h_1, h_2, \dots, h_n \) be the heights of the trees. The tree at position \(i\) is visible if:
\( h_i > \max\{h_1, h_2, \dots, h_{i-1}\} \)
Your task is to count the number of visible trees.
inputFormat
The first line contains a non-negative integer n representing the number of trees. If n is greater than 0, the second line contains n space-separated integers representing the heights of the trees.
outputFormat
Output a single integer which is the count of visible trees.
## sample5
3 7 4 6 5
2
</p>