#C10820. Maximum Equal Weight Sum
Maximum Equal Weight Sum
Maximum Equal Weight Sum
You are given T test cases. In each test case, you are given a positive integer N and a list of N integer weights.
Your task is to form as many pairs as possible such that in each pair the two weights are equal. The total weight of a pair is defined as 2 \(\times\) the weight of one element of the pair. For each test case, compute the maximum total weight that can be achieved by pairing the weights.
For a weight \(w\) occurring \(c\) times, you can form \(\lfloor c/2 \rfloor\) pairs, and the contribution is \(2w \times \lfloor c/2 \rfloor\). Sum these contributions over all distinct weights to obtain the answer for the test case.
Input/Output Format: Read input from standard input (stdin) and print the result to standard output (stdout).
inputFormat
The first line contains an integer T representing the number of test cases. The following lines describe the test cases.
For each test case:
- The first line contains an integer N representing the number of weights.
- The second line contains N space-separated integers denoting the weights.
outputFormat
For each test case, output a single line containing the maximum total weight obtainable by forming pairs of equal weights.
## sample2
6
1 1 2 2 3 3
5
1 2 3 3 4
12
6
</p>