#K96167. Counting Sunny Buildings

    ID: 39027 Type: Default 1000ms 256MiB

Counting Sunny Buildings

Counting Sunny Buildings

In this problem, you are given a sequence of building heights. A building is considered "sunny" if it is strictly taller than every building to its left. Formally, for a list of heights ( h_1, h_2, \dots, h_n ), the first building ( h_1 ) is always sunny, and for each building ( h_i ) with ( i > 1 ), it is sunny if ( h_i > \max{h_1, h_2, \dots, h_{i-1}} ). Your task is to compute the number of sunny buildings.

Examples:

  • For input [7, 4, 8, 2, 9, 5], the sunny buildings are 7, 8, and 9, so the answer is 3.
  • For an increasing sequence [1, 2, 3, 4, 5], every building is sunny, so the answer is 5.
  • For a decreasing sequence [5, 4, 3, 2, 1], only the first building is sunny, so the answer is 1.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer ( n ) (( 0 \leq n \leq 10^5 )) representing the number of buildings. The second line contains ( n ) space-separated integers representing the heights of the buildings.

outputFormat

Output a single integer to standard output (stdout) representing the number of sunny buildings.## sample

1
5
1

</p>