看到很多人先把他们依次放入一个数组中,其实复杂度可以进一步降低到,直接通过从两个数组中取出的元素个数进行判断看中值在那个数组里并同时确定他的下标即可。至于为什么下标可以这样表示,画画图就知道了/

int main() {
    ll n1, n2, a, b, c, d;
    while (cin >> n1 >> n2) {
        vec v1(n1 + 1), v2(n2 + 1), v; 
        for (int i = 1; i <= n1; i++)cin >> v1[i];
        for (int i = 1; i <= n2; i++)cin >> v2[i];
        cin >> a >> b >> c >> d;
        ll l1 = b - a + 1, l2 = d - c + 1;
        if (l1 == l2) { 
            if (b < c)cout << v1[b] << endl;
            else cout << v2[c] << endl;
        }
        else if (l1 > l2) {//中位数在左边
            if ((l1 + l2) % 2 == 0)cout << v1[a + (l1 + l2) / 2 - 1] << endl;
            else cout << v1[a + (l1 + l2) / 2] << endl;
        }
        else {
            if ((l1 + l2) % 2 == 0)cout <<  v2[c + (l1 + l2) / 2 - l1 - 1] << endl;
            else cout << v2[c + (l1 + l2) / 2 - l1] << endl;
        }
    }
}