1506D.md (1476B)
1 Source: https://codeforces.com/problemset/problem/1506/D 2 3 D. Epic Transformation 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given an array $a$ of length $n$ consisting of integers. You can apply the following operation, consisting of several steps, on the array $a$ zero or more times: 22 23 * you select two different numbers in the array $a_i$ and $a_j$; 24 * you remove $i$-th and $j$-th elements from the array. 25 26 For example, if $n=6$ and $a=[1, 6, 1, 1, 4, 4]$, then you can perform the following sequence of operations: 27 28 * select $i=1, j=5$. The array $a$ becomes equal to $[6, 1, 1, 4]$; 29 * select $i=1, j=2$. The array $a$ becomes equal to $[1, 4]$. 30 31 What can be the minimum size of the array after applying some sequence of operations to it? 32 33 Input 34 35 The first line contains a single integer $t$ ($1 \le t \le 10^4$). Then $t$ test cases follow. 36 37 The first line of each test case contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$) is length of the array $a$. 38 39 The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$). 40 41 It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. 42 43 Output 44 45 For each test case, output the minimum possible size of the array after applying some sequence of operations to it. 46 47 Example 48 49 Input 50 51 ``` 52 5 53 6 54 1 6 1 1 4 4 55 2 56 1 2 57 2 58 1 1 59 5 60 4 5 4 5 4 61 6 62 2 3 2 1 3 1 63 ``` 64 65 Output 66 67 ``` 68 0 69 0 70 2 71 1 72 0 73 ```