Upload code_segments/segment_119.txt with huggingface_hub
Browse files
code_segments/segment_119.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This is the easy version of the problem. The only difference between the two versions is the constraint on $n$. You can make hacks only if both versions of the problem are solved.
|
| 2 |
+
|
| 3 |
+
You are given an array of integers $a$ of length $n$.
|
| 4 |
+
|
| 5 |
+
In one operation, you will perform the following two-step process:
|
| 6 |
+
|
| 7 |
+
1. Choose an index $i$ such that $1 \le i < |a|$ and $a_i = i$. 2. Remove $a_i$ and $a_{i+1}$ from the array and concatenate the remaining parts.
|
| 8 |
+
|
| 9 |
+
Find the maximum number of times that you can perform the operation above.
|
| 10 |
+
|
| 11 |
+
Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The description of the test cases follows.
|
| 12 |
+
|
| 13 |
+
The first line of each test case contains a single integer $n$ ($1 \le n \le 100$) — the length of the array $a$.
|
| 14 |
+
|
| 15 |
+
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le n$) — the elements of the array $a$.
|
| 16 |
+
|
| 17 |
+
It is guaranteed that the sum of $n$ over all test cases does not exceed $100$.
|
| 18 |
+
|
| 19 |
+
For each test case, output a single integer — the maximum number of times that you can perform the operation.
|
| 20 |
+
|
| 21 |
+
In the first test case, one possible optimal sequence of operations is $[ 1, 5, \color{red}{3}, \color{red}{2}, 4 ] \rightarrow [\color{red}{1}, \color{red}{5}, 4] \rightarrow [4]$.
|
| 22 |
+
|
| 23 |
+
In the third test case, one possible optimal sequence of operations is $[1, \color{red}{2}, \color{red}{3}] \rightarrow [1]$.
|