#C5453. Minimum Number of Strictly Increasing Contiguous Sublists
Minimum Number of Strictly Increasing Contiguous Sublists
Minimum Number of Strictly Increasing Contiguous Sublists
Given an array of integers, your task is to split it into the minimum number of contiguous sublists such that each sublist is strictly increasing. In other words, for every contiguous sublist, if the sublist is [a₁, a₂, (\dots), aₖ)], then it must satisfy (a_1 < a_2 < \dots < a_k). When the sequence is not increasing at some point, a new sublist must begin.
For example, given the array [1, 2, 1, 2], the minimal split is [1, 2] and [1, 2], so the answer is 2. Use an algorithm that efficiently scans the array from left to right and counts the breakpoints where the sequence ceases to be strictly increasing.
inputFormat
The input is read from standard input (stdin) and has the following format:
(T)
For each test case:
- An integer (n) representing the number of elements in the array.
- (n) space-separated integers representing the array elements.
Here, (T) is the number of test cases.
outputFormat
For each test case, output a single line with one integer representing the minimum number of strictly increasing contiguous sublists into which the array can be split. The output is written to standard output (stdout).## sample
2
4
1 2 1 2
3
3 2 1
2
3
</p>