#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=2e5+5;
int a[MAX];
int b[MAX];
int maxpref[MAX],maxsuf[MAX];
int ans[MAX];
int c[MAX];
bool cmp(int i,int j){
return a[i]<a[j];
}
int32_t main()
{
BOOST;
int n;
cin>>n;
for (int i=1;i<=n+1;i++)cin>>a[i];
for (int i=1;i<=n;i++)cin>>b[i];
sort(b+1,b+n+1);
for (int i=1;i<=n+1;i++)c[i]=i;
sort(c+1,c+n+2,cmp);
for (int i=1;i<=n;i++){
int id=c[i];
maxpref[i]=max(maxpref[i-1],abs(a[id]-b[i]));
}
for (int i=n;i>=1;i--){
int id=c[i+1];
maxsuf[i]=max(maxsuf[i+1],abs(a[id]-b[i]));
}
for (int wywal=1;wywal<=n+1;wywal++){
int ilebiore=n-(wywal-1);
ans[c[wywal]]=maxpref[wywal-1]+maxsuf[n+1-ilebiore+1];
}
for (int i=1;i<=n+1;i++)cout<<ans[i]<<" ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |