Median of sorted array

first test case is failing whereas in ide correct output is coming
#include
using namespace std;
int main() {
int n;
cin>>n;
int a[1000],b[1000],c[2000];
int i;
for(i=0;i<n;i++)
cin>>a[i];

for(i=0;i<n;i++)
cin>>b[i];
int j=0;
for(i=0;i<n;i++){
c[j]=a[i];
c[j+1]=b[i];
j=j+2;
}
cout<<(c[n-1]+c[n])/2;

return 0;

}

Hey Pritika, you are not merging the arrays correctly, for eg.
input :
5
1 5 6 12 13
2 3 4 7 8

then your expected merged array would be : 1 2 3 4 5 6 7 8 12 13
but your code’s merged array is : 1 2 5 3 6 4 12 7 13 8

which further results in the wrong median also.