[Solution] All Distinct Codeforces Solution | Codeforces Problem Solution 2022
Sho has an array consisting of integers. An operation consists of choosing two distinct indices and and removing and from the array.
For example, for the array , Sho can choose to remove indices and . After this operation, the array becomes . Note that after any operation, the length of the array is reduced by two.
After he made some operations, Sho has an array that has only distinct elements. In addition, he made operations such that the resulting array is the longest possible.
More formally, the array after Sho has made his operations respects these criteria:
- No pairs such that () and exist.
- The length of is maximized.
Output the length of the final array.
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the array.
The second line of each test case contains integers () — the elements of the array.
For each test case, output a single integer — the length of the final array. Remember that in the final array, all elements are different, and its length is maximum.
No comments:
Post a Comment