CF1930A.Maximise The Score
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
白板上写有 2n 个正整数。你感到无聊,于是决定用白板上的这些数字来玩一个单人游戏。
你的初始得分为 0。你需要恰好执行 n 次如下操作来增加你的得分:
- 从白板上选择两个整数 x 和 y;
- 将 min(x,y) 加入你的得分;
- 将 x 和 y 从白板上擦除。
注意:执行 n 次操作后,白板上将不再有任何整数。
若你能以最优方式执行这 n 次操作,求你能获得的最高最终得分。
输入格式
Each test contains multiple test cases. The first line contains a single integer t (1≤t≤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≤n≤50) — the number of integers written on the whiteboard is 2n.
The second line of each test case contains 2n integers a1,a2,…,a2n (1≤ai≤107) — the numbers written on the whiteboard.
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤5000),表示测试用例的数量。随后是测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤50),表示白板上书写的整数个数为 2n。
每个测试用例的第二行包含 2n 个整数 a1,a2,…,a2n(1≤ai≤107),表示白板上所写的数字。
输出格式
For each test case, output the maximum final score that you can achieve.
对于每个测试用例,输出你能达到的最高最终得分。
输入输出样例
输入#1
3 1 2 3 2 1 1 2 1 3 1 1 1 1 1 1
输出#1
2 2 3
说明/提示
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.
在第一个测试用例中,你只能进行一次操作。你选择 x=2 和 y=3,得分将为 min(x,y)=2。
在第二个测试用例中,以下是一组能获得最终得分为 2 的操作序列:
- 第一次操作:选择 x=1 和 y=1,将 min(x,y)=1 加入得分。擦除 x 和 y 后,白板上剩余的整数为 1 和 2。
- 第二次操作:选择 x=1 和 y=2,将 min(x,y)=1 加入得分。移除 x 和 y 后,白板上将不再剩下任何整数。
可以证明,无法获得高于 2 的得分。
在第三个测试用例中,你将执行三次操作,每次均向得分中加上 1。
输入解题思路,AI测评打分。不知道怎么写?