#include<bits/stdc++.h>
using namespace std;
#define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll
int t, n, m, k, q, l, r;
int b[200010];
int p[200010], s[200010];
pii a[200010];
int c[200010];
int32_t main(){
INIT
cin>>n;
for(int i=1; i<=(n+1); i++){
cin>>a[i].ft; a[i].sc=i;
//a2[i]=a[i];
}
for(int i=1; i<=n; i++){
cin>>b[i];
}
sort(b+1, b+n+1);
sort(a+1, a+2+n);
for(int i=(n+1); i>=2; i--){
s[i]=max(s[i+1], abs(a[i].ft-b[i-1]));
}
for(int i=1; i<=n; i++){
p[i]=max(p[i-1], abs(a[i].ft-b[i]));
}
for(int i=1; i<=(n+1); i++){
c[a[i].sc ]=max(p[i-1], s[i+1]);
}
for(int i=1; i<=(n+1); i++){
cout<<c[i]<<" ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |