#include<bits/stdc++.h>
#define ll long long
using namespace std;
pair<ll,ll> a[200010]={};
ll pref[200010]={},preb[200010]={},b[200010]={},ans[200010]={};
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
for(int i=1;i<=n+1;i++){
cin>>a[i].first;
a[i].second=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++){
pref[i]=max(pref[i-1],abs(a[i].first-b[i]));
}
for(int i=1;i<=n;i++){
preb[i]=max(preb[i-1],abs(a[n+2-i].first-b[n+1-i]));
}
for(int i=0;i<=n;i++){
ans[a[i+1].second]=max(preb[n-i],pref[i]);
}
for(int i=1;i<=n+1;i++){
cout<<ans[i]<<" ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |