#K55457. Maximal Rectangular Plots
Maximal Rectangular Plots
Maximal Rectangular Plots
You are given several test cases. In each test case, you are provided with a sequence of integers representing the lengths of wooden poles. Your task is to determine the maximum number of rectangular plots that can be constructed using the poles. A rectangle requires two pairs of poles of equal length. Formally, for each test case, if a pole of length L occurs c times, then it can contribute \(\lfloor c/2 \rfloor\) pairs. A rectangle needs two such pairs, so the number of rectangles you can form is \(\lfloor (\text{total pairs})/2 \rfloor\).
Input Format: The first line contains an integer \(T\) denoting the number of test cases. For each test case, there is a line with an integer \(N\) representing the number of poles, followed by a line containing \(N\) space-separated integers representing the lengths of the wooden poles.
Output Format: For each test case, output a single integer which is the maximum number of rectangular plots that can be constructed. Output the results for all test cases on separate lines.
inputFormat
The input is provided via standard input (stdin). The first line contains an integer \(T\) (\(1 \leq T \leq 100\)), the number of test cases. For each test case, the first line contains an integer \(N\) (the number of wooden poles), followed by a line with \(N\) space-separated integers representing the lengths of the poles.
Example:
2
8
1 2 2 1 2 2 1 1
7
4 4 4 4 4 5 5
outputFormat
For each test case, output a single line containing an integer representing the maximum number of rectangular plots that can be formed, where each rectangle requires two pairs of poles with equal lengths.
Example:
2
1
2
8
1 2 2 1 2 2 1 1
7
4 4 4 4 4 5 5
2
1
</p>