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>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,f[200009],pr[200009],sf[200009],A[200009],B[200009],ans[200009];
pair <long long, long long> p[200009];
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;
for(i=1; i<=a+1; i++){
cin>>A[i];
p[i]={A[i],i};
}
for(i=1; i<=a; i++){
cin>>B[i];
}
sort(A+1,A+a+2);
sort(B+1,B+a+1);
sort(p+1,p+a+2);
for(i=1; i<=a; i++){
pr[i]=max(pr[i-1],A[i]-B[i]);
}
for(i=a; i>=1; i--){
sf[i]=max(sf[i+1],A[i+1]-B[i]);
}
for(i=1; i<=a+1; i++){
//cout<<max(pr[i-1],sf[i])<<" ";
ans[p[i].second]=max(pr[i-1],sf[i]);
}
for(i=1; i<=a+1; i++){
cout<<ans[i]<<" ";
}
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... |