#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
//freopen("in.txt","r",stdin);
queue<int> q1,q2;
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
ll temp;scanf("%lld",&temp);
temp=min((long long)INT_MAX, temp);
q1.push(temp);
}
q1.push(INT_MAX);
int m;scanf("%d",&m);int cnt=0;
int target=(m+n-1)/2;
for(int i=0;i<m;i++){
ll temp;scanf("%lld",&temp);
temp=min((long long)INT_MAX, temp);
q2.push(temp);
if(cnt==target){
printf("%lld",min(q1.front(),q2.front()));
return 0;
}
if(q1.front()<q2.front()) q1.pop();
else q2.pop();
cnt++;
}
q2.push(INT_MAX);
while(cnt!=target){
if(q1.front()<q2.front()){
q1.pop();
}
else{
q2.pop();
}
cnt++;
}
printf("%lld",min(q1.front(),q2.front()));
return 0;
}
1029 Median
猜你喜欢
转载自blog.csdn.net/csg3140100993/article/details/82048914
今日推荐
周排行