#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=3e5+5;
int N,niz[2*maxn],R[maxn],B[maxn];
int resi(){
vector<int> A,BB;
int ret=1e9;
for(int p=1;p<=N+1;p++){
int k=p+N-1;
int tmp=0;
A.clear();
BB.clear();
for(int i=1;i<=2*N;i++)
if(i>=p and i<=k)
A.push_back(niz[i]);
else
BB.push_back(niz[i]);
sort(A.begin(),A.end());
sort(BB.begin(),BB.end());
for(int i=1;i<=N;i++){
tmp=max(tmp,abs(R[i]-A[i-1]));
tmp=max(tmp,abs(B[i]-BB[i-1]));
}
ret=min(ret,tmp);
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>N;
for(int i=1;i<=2*N;i++)
cin>>niz[i];
for(int i=1;i<=N;i++)
cin>>R[i];
for(int i=1;i<=N;i++)
cin>>B[i];
sort(R+1,R+1+N);
sort(B+1,B+1+N);
int res=resi();
for(int i=1;i<=N;i++)
swap(R[i],B[i]);
res=min(res,resi());
cout<<res<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
343 ms |
604 KB |
Output is correct |
27 |
Correct |
342 ms |
568 KB |
Output is correct |
28 |
Correct |
174 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
368 ms |
604 KB |
Output is correct |
31 |
Correct |
324 ms |
348 KB |
Output is correct |
32 |
Correct |
68 ms |
348 KB |
Output is correct |
33 |
Correct |
17 ms |
348 KB |
Output is correct |
34 |
Correct |
369 ms |
604 KB |
Output is correct |
35 |
Correct |
380 ms |
564 KB |
Output is correct |
36 |
Correct |
341 ms |
604 KB |
Output is correct |
37 |
Correct |
120 ms |
468 KB |
Output is correct |
38 |
Correct |
156 ms |
604 KB |
Output is correct |
39 |
Correct |
180 ms |
604 KB |
Output is correct |
40 |
Correct |
353 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5014 ms |
20940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
343 ms |
604 KB |
Output is correct |
27 |
Correct |
342 ms |
568 KB |
Output is correct |
28 |
Correct |
174 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
368 ms |
604 KB |
Output is correct |
31 |
Correct |
324 ms |
348 KB |
Output is correct |
32 |
Correct |
68 ms |
348 KB |
Output is correct |
33 |
Correct |
17 ms |
348 KB |
Output is correct |
34 |
Correct |
369 ms |
604 KB |
Output is correct |
35 |
Correct |
380 ms |
564 KB |
Output is correct |
36 |
Correct |
341 ms |
604 KB |
Output is correct |
37 |
Correct |
120 ms |
468 KB |
Output is correct |
38 |
Correct |
156 ms |
604 KB |
Output is correct |
39 |
Correct |
180 ms |
604 KB |
Output is correct |
40 |
Correct |
353 ms |
348 KB |
Output is correct |
41 |
Execution timed out |
5014 ms |
20940 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |