#C3041. Counting Bird Moves

    ID: 46425 Type: Default 1000ms 256MiB

Counting Bird Moves

Counting Bird Moves

A bird is traveling along a row of trees. The bird starts at the first tree and then continues moving from left to right. Every time it encounters a tree that is taller than all the trees it has seen so far, it moves to that tree.

Mathematically, if the tree heights are given by \(a_1, a_2, \dots, a_n\), the number of moves is defined as:

\[ \text{moves} = \sum_{i=2}^{n} \mathbf{1}_{\{a_i > \max(a_1, a_2, \dots, a_{i-1})\}} \]

Your task is to compute the number of such moves based on the list of tree heights given as input.

inputFormat

The input is given from standard input (stdin) and consists of two lines. The first line contains an integer \(n\) representing the number of trees. The second line contains \(n\) space-separated integers representing the heights of the trees.

For example:

5
2 3 4 3 5

outputFormat

Output a single integer that represents the number of times the bird moves to a tree that is taller than all the previous trees, printed to standard output (stdout).

For the sample input above, the output should be:

3
## sample
5
2 3 4 3 5
3