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 ll long long
#define ff first
#define ss second
using namespace std;
const int N = 1e6 + 69;
int n,x;
int B[N],ANS[N];
pair<int,int> A[N];
set< pair<int,int> > S;
int main(){
cin>>n;
for(int i=1;i<=n+1;i++){
cin>>x;
A[i] = {x,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=2;i<=n+1;i++){
S.insert( { max(A[i].ff-B[i-1],0), i } );
}
ANS[ A[1].ss ] = (*S.rbegin()).ff;
for(int i=2;i<=n+1;i++){
S.erase( { max(A[i].ff-B[i-1],0), i } );
S.insert( { max(A[i-1].ff-B[i-1],0), i-1 } );
ANS[ A[i].ss ] = (*S.rbegin()).ff;
}
for(int i=1;i<=n+1;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... |