-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1353B.c
More file actions
48 lines (48 loc) · 1.04 KB
/
Copy path1353B.c
File metadata and controls
48 lines (48 loc) · 1.04 KB
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
#include<stdio.h>
int main(){
int t,n,k;
scanf("%d",&t);
for(int i=0;i<t;i++){
scanf("%d %d",&n,&k);
int a[n],b[n];
for(int j=0;j<n;j++){
scanf("%d",&a[j]);
}
for(int j=0;j<n;j++){
scanf("%d",&b[j]);
}
for(int j=0;j<n;j++){
for(int k=j+1;k<n;k++){
if(a[j]>a[k]){
int tem=a[j];
a[j]=a[k];
a[k]=tem;
}
}
}
for(int j=0;j<n;j++){
for(int k=j+1;k<n;k++){
if(b[j]<b[k]){
int tem=b[j];
b[j]=b[k];
b[k]=tem;
}
}
}
int x;
int sum=0;
for(x=0;x<k;x++){
if(a[x]>=b[x]){
sum=sum+a[x];
}
else{
sum=sum+b[x];
}
}
for(x=x;x<n;x++){
sum=sum+a[x];
}
printf("%d\n",sum);
}
return 0;
}