1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 int main() 6 { 7 int N; 8 cin >> N; 9 vector<int> s1, s2, s3; 10 for (int i = 0; i < N; i++) 11 { 12 int in; 13 cin >> in; 14 s1.push_back(in); 15 } 16 for (int i = 0; i < N; i++) 17 { 18 int in; 19 cin >> in; 20 s2.push_back(in); 21 } 22 int p1 = 0; 23 int p2 = 0; 24 for (int i = 0; i < 2*N; i++) 25 { 26 if (p1 < N && p2 < N) 27 {//注意下标边界问题,下标为N时不能使用s1[p1]或s2[p2] 28 if (s1[p1] < s2[p2]) 29 s3.push_back(s1[p1++]); 30 else 31 s3.push_back(s2[p2++]); 32 } 33 else 34 { 35 if(p1 < N)s3.push_back(s1[p1++]); 36 else s3.push_back(s2[p2++]); 37 } 38 } 39 cout << s3[(2*N-1)/2] <<endl; 40 return 0; 41 }