이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
#define pil pair<int,long long>
const int maxn=2e5+9;
pii a[maxn];
int b[maxn],c[maxn],d[maxn];
int ans[maxn];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("temp.INP","r",stdin);
//freopen("temp.OUT","w",stdout);
int n;
cin>>n;
for1(i,1,n+1){
cin>>a[i].fi;
a[i].se=i;
}
for1(i,1,n)cin>>b[i];
sort(a+1,a+n+2);
sort(b+1,b+n+1);
for1(i,1,n){
c[i]=max(c[i-1],max(0,a[i].fi-b[i]));
}
for2(i,n+1,2){
d[i]=max(d[i+1],max(0,a[i].fi-b[i-1]));
}
for1(i,1,n+1){
ans[a[i].se]=max(d[i+1],c[i-1]);
}
for1(i,1,n+1)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... |