#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
const int inf = 1e9 + 5;
signed main() {
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(all(b));
sort(all(c));
int ans = inf;
for (int i = 0; i < n; i ++) {
vector<int> vb, vc;
for (int j = 0; j < i; j ++)
vb.push_back(a[j]);
for (int j = i; j < i + n; j ++)
vc.push_back(a[j]);
for (int j = i + n; j < 2 * n; j ++)
vb.push_back(a[j]);
sort(all(vb));
sort(all(vc));
int mx = 0;
for (int j = 0; j < n; j ++) {
mx = max(mx, abs(vb[j] - b[j]));
mx = max(mx, abs(vc[j] - c[j]));
}
ans = min(ans, mx);
for (int j = 0; j < n; j ++) {
mx = max(mx, abs(vc[j] - b[j]));
mx = max(mx, abs(vb[j] - c[j]));
}
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... |