#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+7;
int seg[N<<2];
void update(int i, int cL, int cR, int l, int r, int x)
{
if (cR<l||r<cL)
return;
if (l<=cL&&cR<=r)
{
seg[i]=max(seg[i],x);
return;
}
update(i*2+1,cL,cL+(cR-cL)/2,l,r,x);
update(i*2+2,cL+(cR-cL)/2+1,cR,l,r,x);
}
void ans(int i, int l, int r)
{
if (l==r)
{
cout<<seg[i]<<" ";
return;
}
seg[i*2+1]=max(seg[i*2+1],seg[i]);
seg[i*2+2]=max(seg[i*2+2],seg[i]);
ans(i*2+1,l,l+(r-l)/2);
ans(i*2+2,l+(r-l)/2+1,r);
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin>>n;
int a[n+2],b[n+1];
for (int i=1;i<=n+1;++i)
cin>>a[i];
for (int i=1;i<=n;++i)
cin>>b[i];
sort(a+1,a+n+2);
sort(b+1,b+n+1);
for (int i=1;i<=n;++i)
{
update(0,1,n+1,1,i,abs(b[i]-a[i+1]));
update(0,1,n+1,i+1,n+1,abs(b[i]-a[i]));
}
ans(0,1,n+1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |