Two Arrays And Swaps
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Two Arrays And Swaps
题面翻译
有两个长度都为 的整数序列 。
可以进行最多 次操作:选定 ( 可以相同),交换 。
求操作结束后 序列元素的和的最大值。
题目描述
You are given two arrays and both consisting of positive (greater than zero) integers. You are also given an integer .
In one move, you can choose two indices and ( ) and swap and (i.e. becomes and vice versa). Note that and can be equal or different (in particular, swap with or swap and both are acceptable moves).
Your task is to find the maximum possible sum you can obtain in the array if you can do no more than (i.e. at most) such moves (swaps).
You have to answer independent test cases.
输入格式
The first line of the input contains one integer ( ) — the number of test cases. Then test cases follow.
The first line of the test case contains two integers and ( ) — the number of elements in and and the maximum number of moves you can do. The second line of the test case contains integers ( ), where is the -th element of . The third line of the test case contains integers ( ), where is the -th element of .
输出格式
For each test case, print the answer — the maximum possible sum you can obtain in the array if you can do no more than (i.e. at most) swaps.
样例 #1
样例输入 #1
5
2 1
1 2
3 4
5 5
5 5 6 6 5
1 2 5 4 3
5 3
1 2 3 4 5
10 9 10 10 9
4 0
2 2 4 3
2 4 2 3
4 4
1 2 2 1
4 4 5 4
样例输出 #1
6
27
39
11
17
提示
In the first test case of the example, you can swap and , so and .
In the second test case of the example, you don't need to swap anything.
In the third test case of the example, you can swap and , and and and , so and .
In the fourth test case of the example, you cannot swap anything.
In the fifth test case of the example, you can swap arrays and , so and .
20230218排序进阶随堂测验
- Status
- Done
- Rule
- Ledo
- Problem
- 10
- Start at
- 2023-2-18 10:30
- End at
- 2023-2-18 11:30
- Duration
- 1 hour(s)
- Host
- Partic.
- 42