Merge function is not working

I tried to use merge function to solve median of sorted array
code :
#include
#include
#include
using namespace std;
int main() {

vector<int> arr1;
vector<int> arr2;
vector<int> arr3;
int n;
cin>>n;

for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
	arr1.push_back(temp);
}

for(int j=0;j<n;j++){
	int temp;
    cin>>temp;
	arr2.push_back(temp);

}
sort(arr1.begin(),arr1.end());
sort(arr2.begin(),arr2.end());

merge(arr1.begin(),arr1.end(),arr2.begin(),arr2.end(),arr3.begin());

int result=(arr3[(2*n-1)/2] + arr3[n])/2;
cout<<result;


return 0;

}

Give the size of the vector 3 in the declaration.
I have fixed it. Have a look

Probably merge is working in this way : merger(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c.begin());

Its fine both ways.
Your code was fine but you need to give size of the 3rd vector.