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 F first
#define S second
#define MAX 500005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
ll n,t[MAX],a[MAX];
pll b[MAX],r[MAX];
int main(){
cin>>n;
for(int i=0;i<=n;i++){
cin>>b[i].F;b[i].S=i;
}
for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);sort(b,b+(n+1));
t[n-1]=max((ll)0,b[n].F-a[n-1]);
for(int i=n-2;i>=0;i--){
t[i]=max(t[i+1],max((ll)0,b[i+1].F-a[i]));
}ll s=0;
for(int i=0;i<n;i++){
r[i].S=max(s,t[i]);r[i].F=b[i].S;
s=max(s,max((ll)0,b[i].F-a[i]));
}r[n].S=s;r[n].F=b[n].S;
sort(r,r+(n+1));
for(int i=0;i<=n;i++)cout<<r[i].S<<" ";
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... |