Analysis : Find the median of the two arrays after merging, even cases: 1, 2, 3, 4 median is 2
I didn’t dare to try because the pass rate was so low when I wrote it for the first time, but I used a simple method to review this time.
Seeing other people say that they want to show off, but~~~
#include <iostream>
#include<cstring>
#include<vector>
#include<stdio.h>
#include<queue>
#include<math.h>
#include<stack>
#include<algorithm>
#include<map>
#include<set>
#define MAX 99999999
using namespace std;
typedef long long ll;
ll a[4000001];
int main()
{
ll n,m;
scanf("%lld",&n);
ll i =0;
for(i = 0;i<n;i++){
scanf("%lld",&a[i]);
}
scanf("%lld",&m);
for(;i<m+n;i++){
scanf("%lld",&a[i]);
}
sort(a,a+n+m);
ll med = (n+m)/2;
if((n+m) % 2 == 0)
med --;
cout<<a[med];
return 0;
}