#K49452. Minimum Speed Adjustments
Minimum Speed Adjustments
Minimum Speed Adjustments
You are given a train traveling through a tunnel composed of several sections. Each section has a specific speed limit. In order to comply with these limits, the train may need to adjust its speed when moving from one section to the next.
Your task is to compute the minimum number of speed adjustments required for the train to pass through the tunnel without violating the speed restrictions.
Formally, for a tunnel divided into N sections, let the speed limits be \(a_1, a_2, \dots, a_N\). The number of adjustments needed is given by:
\[ \sum_{i=2}^{N} \mathbf{1}_{\{a_i \neq a_{i-1}\}}, \] where \(\mathbf{1}\) is the indicator function.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(T\) representing the number of test cases.
- For each test case:
- The first line contains an integer \(N\) representing the number of sections in the tunnel.
- The next line contains \(N\) space-separated integers, which are the speed limits for each section.
outputFormat
For each test case, output a single integer on a separate line indicating the minimum number of speed adjustments required.
The output should be written to standard output (stdout).
## sample3
5
4 3 5 2 1
4
1 1 1 1
6
6 5 4 3 2 1
4
0
5
</p>