#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3e5;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(2 * n), b(n), c(n);
for (int i = 0; i < 2 * n; ++i) {
cin >> a[i];
}
for (int i = 0; i < n; ++i) {
cin >> b[i];
}
for (int i = 0; i < n; ++i) {
cin >> c[i];
}
sort(b.begin(), b.end());
sort(c.begin(), c.end());
int ans = 1e9;
for (int st = 0; st < 2 * n; ++st) {
vector<int> xs, ys;
for (int j = 0; j < 2 * n; ++j) {
if (j < n) {
xs.push_back(a[(st + j) % (2 * n)]);
} else {
ys.push_back(a[(st + j) % (2 * n)]);
}
}
sort(xs.begin(), xs.end());
sort(ys.begin(), ys.end());
int mx = 0;
for (int i = 0; i < n; ++i) {
mx = max(mx, abs(xs[i] - b[i]));
mx = max(mx, abs(ys[i] - c[i]));
}
ans = min(ans, mx);
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |