-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1353B.cpp
59 lines (50 loc) · 1.36 KB
/
1353B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//<<<<<<<<<<<<<Tushars_07>>>>>>>>>>>>>>>>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ll long long
#define no cout<<"NO \n";
#define yes cout<<"YES \n";
#define test lli trtyuio ; cin>>trtyuio; while(trtyuio--)
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
test{
int a , b ;
cin >> a >> b ;
vector<int> arr1 , arr2 ;
for(int i = 0 ; i<a ; i++){
int n ;
cin >> n ;
arr1.push_back(n);
}
for(int i = 0 ; i<a ; i++){
int n ;
cin >> n ;
arr2.push_back(n);
}
int n = 0 ;
int loop = 0 ;
int l = arr1.size()-1 ;
sort(arr1.begin(),arr1.end());
sort(arr2.begin(),arr2.end());
while(loop<b){
if(arr1[n]<arr2[l]){
swap(arr1[n],arr2[l]);
n++;
l--;
loop++;
}
else{
l--;
}
}
int sum = 0 ;
for(int i = 0 ; i<arr1.size() ; i++){
sum = sum + arr1[i];
}
cout<<sum ;
}
return 0;
}
//<<<<<<<<<<Tushars_07>>>>>>>>>>>>>>>>