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;
#define int long long
#define N 200010
#define pii pair<int,int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb emplace_back
int b[N];
pii a[N];
vector<pii>ans;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,i,j;
cin>>n;
for(i=0;i<=n;i++) cin>>a[i].ff,a[i].ss=i;
for(i=0;i<n;i++) cin>>b[i];
sort(a,a+n+1);
sort(b,b+n);
int mx=0;
for(i=0;i<n;i++) mx=max(mx,a[i].ff-b[i]);
ans.pb(a[i].ss,mx);
for(i=n-1;i>=0;i--){
mx=max(mx,a[i+1].ff-b[i]);
ans.pb(a[i].ss,mx);
}
sort(all(ans));
for(auto u:ans) cout<<u.ss<<' ';
}
Compilation message (stderr)
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:16:10: warning: unused variable 'j' [-Wunused-variable]
16 | int n,i,j;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |