#C11155. Maximum Consecutive Jumps
Maximum Consecutive Jumps
Maximum Consecutive Jumps
You are given the heights of a sequence of buildings. Starting from the first building, you can jump consecutively to the next building only if its height is not less than the current building's height. Formally, if the heights are given by (h_1, h_2, \ldots, h_N), you start at (h_1) and can jump to (h_2) if (h_2 \ge h_1), then to (h_3) if (h_3 \ge h_2), and so on, until a building does not satisfy the condition. Your task is to compute the maximum number of consecutive buildings (including the starting one) that can be visited for each test case.
Example 1:
Input: 5 and [1, 2, 2, 3, 2]
Output: 4
Explanation: Starting at 1, you can jump to 2, then another 2, and finally 3. When you reach 2 (after 3) the condition fails since 2 < 3.
Example 2:
Input: 5 and [5, 4, 3, 2, 1]
Output: 1
Explanation: No jump is possible since each subsequent building is lower than the current one.
inputFormat
Input is given via standard input (stdin). The first line contains an integer (T) representing the number of test cases. For each test case, the first line contains an integer (N) denoting the number of buildings, followed by a line with (N) space-separated integers representing the heights of the buildings.
outputFormat
For each test case, output a single integer on a new line which is the maximum number of consecutive buildings that can be jumped to starting from the first building.## sample
1
5
1 2 2 3 2
4
</p>