getting wrong answer in ZCO16001

#include <bits/stdc++.h>
using namespace std;
//int skew(int arr1[], int arr2[], int k,int n)
//{

// return (arr1[n]+arr2[n]);

//}

int main() {
// your code goes here
int n,k,i,arr1[100000],arr2[100000];
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
{
scanf("%d",&arr1[i]);

}

for(i=0;i<n;i++)	
{
    scanf("%d",&arr2[i]);
    

}
for(i=0;i<n;i++)
{
    printf("%d\n",arr1[i]);
    
}

for(i=0;i<n;i++)	
{
    printf("%d\n",arr2[i]);
    

}
sort(arr1,arr1 + n);
sort(arr2,arr2 + n);
//int l= skew( arr1,  arr2,  k, n);

// printf(“l is %d”,l);
while(k–)
{ if(arr2[n]>=arr1[n])
{
swap(arr2[1],arr1[n]);
sort(arr1,arr1 + n);
sort(arr2,arr2 + n);

}
else
{swap(arr1[1],arr2[n]);
sort(arr1,arr1 + n);
sort(arr2,arr2 + n);

}
}
// printf(“array 1\n”);
//for(int i=0;i<n;i++)
// {
// printf("%d\n",arr1[i]);

/* }
printf("------------------");
printf(“array 2\n”);

for( int i=0;i<n;i++)	
{
    printf("%d\n",arr2[i]);
    

}*/
printf("%d",(arr1[n]+arr2[n]));
return 0;

}