This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int N = 3e5+10, MOD = 1e9+7;
const ll INF = 1e18+10;
void solve() {
int n; cin >> n;
vector<ll> a(2 * n); for (auto& x : a) cin >> x;
vector<ll> b(n); for (auto& x : b) cin >> x;
vector<ll> c(n); for (auto& x : c) cin >> x;
sort(b.begin(), b.end());
sort(c.begin(), c.end());
ll ans = INF;
for (int tt = 0; tt < 2; tt++) {
for (int i = 0; i <= n; i++) {
vector<ll> one, two;
for (int rep = 0; rep < n; rep++) {
one.push_back(a[(i + rep) % (2 * n)]);
}
for (int rep = 1; rep <= n; rep++) {
two.push_back(a[(i - rep + 2 * n) % (2 * n)]);
}
sort(one.begin(), one.end());
sort(two.begin(), two.end());
ll cur = 0;
for (int j = 0; j < n; j++) {
cur = max(cur, abs(one[j] - b[j]));
cur = max(cur, abs(two[j] - c[j]));
}
ans = min(ans, cur);
}
swap(b, c);
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int T = 1;
// cin >> T;
while (T--) solve();
}
# | 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... |