제출 #925438

#제출 시각아이디문제언어결과실행 시간메모리
925438XiaoyangJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
79 ms16464 KiB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 1ll<<60
#define rep(i,a,b) for (ll i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
#define endl "\n"
void inc(ll &a,ll b) {a=(a+b)%mod;}
void dec(ll &a,ll b) {a=(a-b+mod)%mod;}
int prod(ll a,ll b) {return ll(a)*ll(b)%mod;}
int lowbit(ll x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
 
const ll maxn=222222;
pll a[maxn];
ll b[maxn],l[maxn],r[maxn],ans[maxn];


signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;cin>>n;
	rep(i,1,n+2)cin>>a[i].fi,a[i].se=i;
	rep(i,1,n+1)cin>>b[i];
	sort(a+1,a+n+2);
	sort(b+1,b+n+1);
	rep(i,1,n+1)l[i]=max(l[i-1],a[i].fi-b[i]);
	for(ll i=n+1;i>1;i--)r[i]=max(r[i+1],a[i].fi-b[i-1]);
	rep(i,1,n+2)ans[a[i].se]=max(l[i-1],r[i+1]);
	rep(i,1,n+2)cout<<ans[i]<<" ";	
	return 0;
}
/*

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...