#C6099. Unobstructed Building Views

    ID: 49821 Type: Default 1000ms 256MiB

Unobstructed Building Views

Unobstructed Building Views

You are given a series of test cases, where each test case consists of a sequence of building heights. Each building's height is a positive integer representing its height.

A building has an unobstructed view of the sunset if there is no building to its right that is taller or of equal height. In other words, for a building at position i with height \(h_i\), it has an unobstructed view if \(h_i > \max\{h_{i+1}, h_{i+2}, \ldots, h_N\}\). The sunset is always considered to be on the right side.

Your task is to compute, for each test case, the number of buildings that have an unobstructed view of the sunset.

inputFormat

The input begins with an integer T, the number of test cases. For each test case, there are two lines:

  • The first line contains an integer N, the number of buildings.
  • The second line contains N space-separated integers representing the heights of the buildings.

outputFormat

For each test case, output a single integer on a new line representing the number of buildings with an unobstructed view of the sunset.

## sample
3
5
3 7 8 3 6
4
4 3 2 1
6
1 3 2 4 5 3
2

4 2

</p>