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 fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e16;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N],n,maxi1[N],maxi2[N],res[N];
pair<int,int>sorted[N];
void solve(){
cin>>n;
for(int i=1;i<=n+1;i++){
cin>>sorted[i].fi;
sorted[i].se=i;
}
sort(sorted+1,sorted+2+n);
for(int i=1;i<=n;i++) cin>>t[i];
sort(t+1,t+1+n);
for(int i=1;i<=n;i++)
maxi1[i]=max(maxi1[i-1],sorted[i].fi-t[i]);
for(int i=n+1;i>=2;i--)
maxi2[i]=max(maxi2[i+1],sorted[i].fi-t[i-1]);
for(int i=1;i<=n+1;i++)
res[sorted[i].se]=max(maxi1[i-1],maxi2[i+1]);
for(int i=1;i<=n+1;i++) cout<<res[i]<<" ";
cout<<"\n";
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
int tt=1;
while(tt--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |