#C1115. Maximum Fruit Pairs
Maximum Fruit Pairs
Maximum Fruit Pairs
Problem Description:
You are given a set of fruits, each with a specified sweetness level. Your task is to determine the maximum number of pairs of fruits that can be formed where each pair consists of fruits having the same sweetness level. Two fruits form a valid pair if their sweetness levels are equal.
The number of pairs for a given sweetness level with count (c) is calculated as (\lfloor c/2 \rfloor). The overall answer for a test case is the sum of these values for all distinct sweetness levels, i.e., (P = \sum_{i=1}^{k} \lfloor c_i/2 \rfloor), where (c_i) is the count of fruits with the i-th unique sweetness.
inputFormat
Input Format:
The first line contains an integer (T), the number of test cases. Each test case is described using two lines:
1. An integer (N) representing the number of fruits.
2. (N) space-separated integers representing the sweetness levels of the fruits.
outputFormat
Output Format:
For each test case, output a single line containing one integer—the maximum number of pairs of fruits with the same sweetness level.## sample
3
6
1 2 3 2 3 1
7
4 4 4 4 4 4 4
5
1 2 3 4 5
3
3
0
</p>