/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
int n;
ll a[N];
ll b[N];
ll c[N];
void solve(){
cin >> n;
for(int i = 1; i <= n*2; ++i) cin >> a[i];
for(int i = 1; i <= n; ++i) cin >> b[i];
for(int i = 1; i <= n; ++i) cin >> c[i];
sort(b+1,b+1+n);
sort(c+1,c+1+n);
ll ans = 1e18;
for(int i = 1; i <= n+1; ++i){
ll cost=0;
vector<ll> x, y;
for(int j=1;j<=2*n;++j){
if(j<i||j>=i+n) x.pb(a[j]);
else y.pb(a[j]);
}
sort(all(x));
sort(all(y));
for(int j=0;j<n;++j) cost=max(cost,abs(x[j]-b[j+1]));
for(int j=0;j<n;++j) cost=max(cost,abs(y[j]-c[j+1]));
ans=min(ans,cost);
}
cout<<ans;
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(tt--){
solve();
en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
# | 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... |