## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Odd Subarrays Codeforces Solution | Codeforces Problem Solution 2022

B. Odd Subarrays
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

For an array $\left[{b}_{1},{b}_{2},\dots ,{b}_{m}\right]$ define its number of inversions as the number of pairs $\left(i,j\right)$ of integers such that $1\le i and ${b}_{i}>{b}_{j}$. Let's call array $b$ odd if its number of inversions is odd.

For example, array $\left[4,2,7\right]$ is odd, as its number of inversions is $1$, while array $\left[2,1,4,3\right]$ isn't, as its number of inversions is $2$.

You are given a permutation $\left[{p}_{1},{p}_{2},\dots ,{p}_{n}\right]$ of integers from $1$ to $n$ (each of them appears exactly

once in the permutation). You want to split it into several consecutive subarrays (maybe just one), so that the number of the odd subarrays among them is as large as possible.

What largest number of these subarrays may be odd?

Input

The first line of the input contains a single integer $t$ ($1\le t\le {10}^{5}$)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($1\le n\le {10}^{5}$)  — the size of the permutation.

The second line of each test case contains $n$ integers ${p}_{1},{p}_{2},\dots ,{p}_{n}$ ($1\le {p}_{i}\le n$, all ${p}_{i}$ are distinct)  — the elements of the permutation.

The sum of $n$ over all test cases doesn't exceed $2\cdot {10}^{5}$.

Output

For each test case output a single integer  — the largest possible number of odd subarrays that you can get after splitting the permutation into several consecutive subarrays.