think-cell Round 1
A
Maximise The Score
Codeforces
800
原题
←B →
翻译中…

There are $2n$ positive integers written on a whiteboard. Being bored, you decided to play a one-player game with the numbers on the whiteboard.

翻译中…

You start with a score of $0$. You will increase your score by performing the following move exactly $n$ times:

翻译中…
  • Choose two integers $x$ and $y$ that are written on the whiteboard.
  • Add $\min(x,y)$ to your score.
  • Erase $x$ and $y$ from the whiteboard.
翻译中…

Note that after performing the move $n$ times, there will be no more integers written on the whiteboard.

翻译中…

Find the maximum final score you can achieve if you optimally perform the $n$ moves.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 5000$) — the number of test cases. The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 50$) — the number of integers written on the whiteboard is $2n$.

翻译中…

The second line of each test case contains $2n$ integers $a_1,a_2,\ldots,a_{2n}$ ($1 \leq a_i \leq 10^7$) — the numbers written on the whiteboard.

翻译中…

Output

翻译中…

For each test case, output the maximum final score that you can achieve.

翻译中…

Note

翻译中…

In the first test case, you can only make one move. You select $x=2$ and $y=3$, and your score will be $\min(x,y)=2$.

翻译中…

In the second test case, the following is a sequence of moves that achieves a final score of $2$:

翻译中…
  • In the first move, select $x=1$ and $y=1$. Then, add $\min(x,y)=1$ to the score. After erasing $x$ and $y$, the integers left on the whiteboard are $1$ and $2$.
  • In the second move, select $x=1$ and $y=2$. Then, add $\min(x,y)=1$ to the score. After removing $x$ and $y$, no more integers will be left on the whiteboard.
翻译中…

It can be proved that it is not possible to get a score greater than $2$.

翻译中…

In the third test case, you will perform the move thrice, adding $1$ to the score each time.

翻译中…

样例

Input #1
3
1
2 3
2
1 1 2 1
3
1 1 1 1 1 1
Output #1
2
2
3
InputCopy OutputCopy
题目信息
题号
1930A
所属比赛
时间限制
1 s
内存限制
256 MB
标签
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。