#C2069. Counting Merged Sections

    ID: 45344 Type: Default 1000ms 256MiB

Counting Merged Sections

Counting Merged Sections

Given an array of integers, you are asked to determine the number of merged sections that can be obtained by splitting the array whenever the order decreases. A new section starts when an element is strictly less than the previous element. Formally, if the array is (a_1, a_2, \ldots, a_n), then for each index (i) ((2 \leq i \leq n)) such that (a_i < a_{i-1}), a new section begins.

For example, in the array [1, 3, 2, 4, 5], the merged sections are ([1, 3]) and ([2, 4, 5]), hence the answer is 2.

inputFormat

The first line contains a single integer (T) denoting the number of test cases. For each test case, the first line contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers.

outputFormat

For each test case, output a single integer on a new line — the number of merged sections.## sample

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

4 2

</p>