이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define gcd __gcd
#define endl '\n'
const int N=200050,M=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
pii a[N];
ll n, b[N], res[N], ans[N];
signed main(){
ios_base::sync_with_stdio(NULL);
cin.tie(nullptr); cout.tie(nullptr);
cin>>n;
for(ll i=0; i<=n; ++i){
cin>>a[i].fi;
a[i].se=i;
}
for(ll i=0; i<n; ++i) cin>>b[i];
sort(a, a+n+1);
sort(b, b+n);
for(ll i=0; i<n; ++i)
res[i+1]=max(res[i], max(0LL, a[i].fi-b[i]));
// for(ll i=0; i<=n; ++i) cout<<res[i]<<" ";
// cout<<endl;
for(ll i=n; i; --i)
res[i-1]=max(res[i], max(0LL, a[i].fi-b[i-1]));
for(ll i=0; i<=n; ++i) ans[a[i].se]=res[i];
for(ll i=0; i<=n; ++i) cout<<ans[i]<<" ";
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... |