#K67437. Ocean View Buildings

    ID: 32642 Type: Default 1000ms 256MiB

Ocean View Buildings

Ocean View Buildings

You are given n buildings in a line, each with a certain height. The buildings are given in order from left to right. A building has an ocean view if all the buildings to its right have a lower height than it. Formally, let \( h_i \) denote the height of the \( i\text{-th} \) building; then the building at position \( i \) has an ocean view if for every \( j > i \), \( h_j < h_i \).

Your task is to determine the number of buildings that have an ocean view.

Note: If there are no buildings (i.e. \( n = 0 \)), output 0.

inputFormat

The input is read from standard input and consists of two lines:

  1. The first line contains a single integer ( n ) representing the number of buildings.
  2. The second line contains ( n ) space-separated integers representing the height of each building from left to right.

For example:

5 1 3 2 4 2

outputFormat

Output a single integer to standard output: the number of buildings with an ocean view.## sample

6
4 2 3 1 5 4
2