| TeamsCode Summer 2024 Novice Division |
|---|
| Закончено |
Given an array $$$a$$$ of $$$n$$$ integers, find the minimum sum of the array after removing two elements of $$$a$$$ and appending their bitwise XOR to the array.
Each test contains multiple test cases. The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of the array $$$a$$$.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2, \ldots ,a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array $$$a$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
—
Tests in subtasks are numbered from $$$1 - 20$$$ with samples skipped. Each test is worth $$$\frac{100}{20}=5$$$ points.
Tests $$$1 - 5$$$ will satisfy $$$t \le 10$$$, $$$n \le 1000$$$.
The remaining tests do not satisfy any additional constraints.
For each test case, output a single integer — the minimum achievable sum.
255 1 1 3 231 4 9
8 12
In the first test case of the sample test, it is optimal to choose the elements $$$2$$$ and $$$3$$$, deleting them and appending $$$1$$$ to the array. This produces a new sum of $$$8$$$.
In the second test case of the sample test, it is optimal to choose the elements $$$1$$$ and $$$9$$$, deleting them and appending $$$8$$$ to the array. This produces a new sum of $$$12$$$.
—
Problem Idea: xug
Problem Preparation: xug
Occurrences: Novice E
| Название |
|---|


