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;
const long long maxn=300000+10;
long long all[maxn][2],n,inf=1e16;
vector<long long>allb,allc;
void vorod(){
cin>>n;
for(long long i=0;i<n;i++){
cin>>all[i][0];
}
for(long long i=n-1;i>=0;i--){
cin>>all[i][1];
}
allb.resize(n);
allc.resize(n);
for(long long i=0;i<n;i++){
cin>>allb[i];
}
for(long long i=0;i<n;i++){
cin>>allc[i];
}
sort(allb.begin(),allb.end());
sort(allc.begin(),allc.end());
}
void solve(){
long long mainres=inf;
for(long long i=0,j=n;i<=n;i++,j--){
vector<long long>av,dov;
long long fake=0;
for(long long h=0;h<i;h++){
av.push_back(all[h][0]);
}
for(long long h=0;h<j;h++){
av.push_back(all[h][1]);
}
for(long long h=i;h<n;h++){
dov.push_back(all[h][0]);
}
for(long long h=j;h<n;h++){
dov.push_back(all[h][1]);
}
sort(av.begin(),av.end());
sort(dov.begin(),dov.end());
// cout<<i<<" "<<j<<" "<<av.size()<<" "<<dov.size()<<"\n";
for(long long i=0;i<n;i++){
fake=max(fake,max(abs(av[i]-allb[i]),abs(dov[i]-allc[i])));
}
mainres=min(mainres,fake);
fake=0;
swap(allb,allc);
for(long long i=0;i<n;i++){
fake=max(fake,max(abs(av[i]-allb[i]),abs(dov[i]-allc[i])));
}
mainres=min(mainres,fake);
}
cout<<mainres<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("inp.txt","r",stdin);
vorod();
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... |