This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
pair<int,int>a[n+2],res[n+2];
int b[n+1];
int pref[n+1],suf[n+2];
suf[0]=-1;
suf[n+1]=pref[0]=0;
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],a[i].first-b[i]);
for(int i=n;i>=1;i--)suf[i]=max(suf[i+1],a[i+1].first-b[i]);
for(int i=1;i<=n+1;i++)res[i]={a[i].second,max(pref[i-1],suf[i])};
sort(res+1,res+n+2);
for(int i=1;i<=n+1;i++)cout<<res[i].second<<" ";
cout<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |