#include <iostream>
#include <vector>
using namespace std;
vector<long> a;
int main(){
int n1,n2;
scanf("%d",&n1);
for(int i = 0;i < n1;i++){
long temp;
scanf("%ld",&temp);
a.push_back(temp);
}
scanf("%d",&n2);
int k = 0;
int mid = (n1 + n2 - 1) / 2;
int x = 0;
for(int i = 0;i < n2;i++){
long temp;
scanf("%ld",&temp);
while(x < n1 && a[x] <= temp){
x++;
k++;
if(k - 1 == mid){
printf("%ld",a[x - 1]);
system("pause");
return 0;
}
}
k++;
if(k - 1 == mid){
printf("%ld",temp);
system("pause");
return 0;
}
}
while(k - 1 < mid){
k++;
x++;
}
printf("%ld",a[x - 1]);
system("pause");
return 0;
}
PAT | A1029 Median
最新推荐文章于 2024-09-16 15:03:26 发布