#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 |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 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 |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 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 |
500 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 |
348 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 |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 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 |
500 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 |
348 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 |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
204 ms |
548 KB |
Output is correct |
27 |
Correct |
193 ms |
348 KB |
Output is correct |
28 |
Correct |
112 ms |
556 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
195 ms |
388 KB |
Output is correct |
31 |
Correct |
194 ms |
344 KB |
Output is correct |
32 |
Correct |
40 ms |
500 KB |
Output is correct |
33 |
Correct |
13 ms |
344 KB |
Output is correct |
34 |
Correct |
195 ms |
348 KB |
Output is correct |
35 |
Correct |
187 ms |
344 KB |
Output is correct |
36 |
Correct |
195 ms |
552 KB |
Output is correct |
37 |
Correct |
77 ms |
548 KB |
Output is correct |
38 |
Correct |
103 ms |
348 KB |
Output is correct |
39 |
Correct |
122 ms |
348 KB |
Output is correct |
40 |
Correct |
217 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5024 ms |
34160 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 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 |
500 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 |
348 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 |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
204 ms |
548 KB |
Output is correct |
27 |
Correct |
193 ms |
348 KB |
Output is correct |
28 |
Correct |
112 ms |
556 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
195 ms |
388 KB |
Output is correct |
31 |
Correct |
194 ms |
344 KB |
Output is correct |
32 |
Correct |
40 ms |
500 KB |
Output is correct |
33 |
Correct |
13 ms |
344 KB |
Output is correct |
34 |
Correct |
195 ms |
348 KB |
Output is correct |
35 |
Correct |
187 ms |
344 KB |
Output is correct |
36 |
Correct |
195 ms |
552 KB |
Output is correct |
37 |
Correct |
77 ms |
548 KB |
Output is correct |
38 |
Correct |
103 ms |
348 KB |
Output is correct |
39 |
Correct |
122 ms |
348 KB |
Output is correct |
40 |
Correct |
217 ms |
556 KB |
Output is correct |
41 |
Execution timed out |
5024 ms |
34160 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |