#K57182. Sunset Views

    ID: 30364 Type: Default 1000ms 256MiB

Sunset Views

Sunset Views

Given a sequence of building heights arranged from left to right, determine the number of buildings that have an unobstructed view of the sunset. The sunset is observed from the right side. A building is said to have a sunset view if it is strictly taller than all buildings to its right. Use an efficient algorithm to compute this count for multiple test cases.

inputFormat

Input is given via standard input. The first line contains a single integer t (t ≥ 1) representing the number of test cases. Each test case starts with an integer n denoting the number of buildings, followed by n space-separated integers representing the heights of the buildings in order from left to right.

outputFormat

For each test case, output one integer on a separate line representing the number of buildings with a sunset view.## sample

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

1 5

</p>