#K76222. Kevin's Hurdle Race
Kevin's Hurdle Race
Kevin's Hurdle Race
Kevin is participating in a hurdle race where he must jump over a series of hurdles arranged in a straight line. Each test case provides the heights of the hurdles in the order they appear. Kevin begins his race at the first occurrence of the minimum hurdle height. Then, he makes a jump and looks for the next hurdle whose height is less than or equal to his current hurdle's height. He repeats this process until he can no longer find a subsequent hurdle that meets the criterion. The number of jumps he makes in each test case is the answer.
Formally, given a hurdle array \(H = [h_1, h_2, \dots, h_n]\), let \(i_0\) be the index of the first occurrence of \(\min\{h_1, h_2, \dots, h_n\}\). Then, for each jump, if \(h_{i_j}\) is the current hurdle height, Kevin finds the smallest index \(i_{j+1} > i_j\) such that \(h_{i_{j+1}} \leq h_{i_j}\) and counts one jump. This process is repeated until no such \(i_{j+1}\) exists.
Note: All formulas are given in \(\LaTeX\) format.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (T), the number of test cases. Each of the following (T) lines represents a test case. Each test case begins with an integer (k) indicating the number of hurdles, followed by (k) space-separated integers representing the heights of the hurdles.
outputFormat
For each test case, output a single line containing the number of jumps Kevin makes before he can no longer continue.## sample
2
5 1 2 3 4 5
4 2 1 2 1
1
2
</p>