AcWing 3500. 取中值
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 2e6 + 10;
int t, n, m, k, l, r, op, x, y;
int a, b, c, d;
int f[N], g[N], p[N];
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> f[i];
}
for (int i = 1; i <= m; i++) {
cin >> g[i];
}
cin >> a >> b >> c >> d;
for (int i = a; i <= b; i++) {
p[++x] = f[i];
}
for (int i = c; i <= d; i++) {
p[++x] = g[i];
}
cout<<p[(x+1)/2];
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}