#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;
if(n>2000){
assert(0);
}
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();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
198 ms |
636 KB |
Output is correct |
27 |
Correct |
191 ms |
548 KB |
Output is correct |
28 |
Correct |
112 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
190 ms |
760 KB |
Output is correct |
31 |
Correct |
191 ms |
600 KB |
Output is correct |
32 |
Correct |
42 ms |
356 KB |
Output is correct |
33 |
Correct |
11 ms |
500 KB |
Output is correct |
34 |
Correct |
208 ms |
632 KB |
Output is correct |
35 |
Correct |
191 ms |
604 KB |
Output is correct |
36 |
Correct |
196 ms |
600 KB |
Output is correct |
37 |
Correct |
80 ms |
600 KB |
Output is correct |
38 |
Correct |
107 ms |
604 KB |
Output is correct |
39 |
Correct |
124 ms |
604 KB |
Output is correct |
40 |
Correct |
212 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
198 ms |
636 KB |
Output is correct |
27 |
Correct |
191 ms |
548 KB |
Output is correct |
28 |
Correct |
112 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
190 ms |
760 KB |
Output is correct |
31 |
Correct |
191 ms |
600 KB |
Output is correct |
32 |
Correct |
42 ms |
356 KB |
Output is correct |
33 |
Correct |
11 ms |
500 KB |
Output is correct |
34 |
Correct |
208 ms |
632 KB |
Output is correct |
35 |
Correct |
191 ms |
604 KB |
Output is correct |
36 |
Correct |
196 ms |
600 KB |
Output is correct |
37 |
Correct |
80 ms |
600 KB |
Output is correct |
38 |
Correct |
107 ms |
604 KB |
Output is correct |
39 |
Correct |
124 ms |
604 KB |
Output is correct |
40 |
Correct |
212 ms |
604 KB |
Output is correct |
41 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
42 |
Halted |
0 ms |
0 KB |
- |