#include <bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
const int N=1e6+10;
const int inf=8e18;
const int mod=1e9+7;
pair<int,int> a[N],b[N],c[N];
signed main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
int T=1;
// cin>>T;
while(T--) {
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].first;
b[i].second=i;
}
sort(a+1,a+n+2);
sort(b+1,b+n+1);
int mx=0;
vector<int>ans(n+2);
for(int i=1;i<=n;i++) {
mx=max(abs(a[i].first-b[i].first),mx);
}
ans[a[n+1].second]=mx;
for(int k=1;k<=n;k++) {
ans[a[k].second]=max(mx,abs(a[k+1].first-b[k].first));
}
for(int i=1;i<ans.size();i++) cout<<ans[i]<<' ';
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |