#include <bits/stdc++.h> using namespace std; #define MAX 1000001 void getDatas(int& len1, int& len2, int (&arr1)[MAX], int (&arr2)[MAX], int& a, int& b, int& c, int& d) { // TLE超时解决办法:使用scanf替换cin scanf("%d %d",&len1,&len2); for (int i = 0; i < len1; i++) scanf("%d",&arr1[i]); for (int i = 0; i < len2; i++) scanf("%d",&arr2[i]); scanf("%d %d %d %d",&a,&b,&c,&d); } int findMid(int& len1, int& len2, int (&arr1)[MAX], int (&arr2)[MAX], int& a, int& b, int& c, int& d) { int midCount=((b-a+1)+(d-c+1)+1)/2; //取中间位置 vector<int> newArr; for(int i=0;i<b-a+1 && i<midCount;i++) newArr.push_back(arr1[a-1+i]); if(midCount>b-a+1) { for(int i=0;i<d-c+1 && i<midCount-(b-a+1);i++) newArr.push_back(arr2[c-1+i]); } return newArr.back(); } int main() { int len1, len2; int arr1[MAX], arr2[MAX]; int a, b, c, d; getDatas(len1, len2, arr1, arr2, a, b, c, d); printf("%d\n",findMid(len1, len2, arr1, arr2, a, b, c, d)); return 0; }