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;
using ll = long long;
ll N;
pair<ll, ll> A[200005];
ll B[200005], R[200005];
ll P[200005], S[200005];
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N;
for(ll i = 1; i <= N + 1; i++){
cin >> A[i].first;
A[i].second = i;
}
for(ll i = 1; i <= N; i++){
cin >> B[i];
}
sort(A + 1, A + N + 2);
sort(B + 1, B + N + 1);
for(ll i = 1; i <= N; i++){
P[i] = max(P[i - 1], A[i].first - B[i]);
}
for(ll i = N; i >= 1; i--){
S[i] = max(S[i + 1], A[i + 1].first - B[i]);
}
for(ll i = 1; i <= N + 1; i++){
R[A[i].second] = max(P[i - 1], S[i]);
}
for(ll i = 1; i <= N + 1; i++){
cout << R[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... |