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 pii = pair<int, int>;
#define ff first
#define ss second
int N, B[200005], P[200005], S[200005], C[200005];
pii A[200005];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> N;
for (int i = 1; i <= N + 1; ++i) {
int x; cin >> x;
A[i] = {x, i};
}
for (int i = 1; i <= N; ++i) cin >> B[i];
sort(A + 1, A + N + 2);
sort(B + 1, B + N + 1);
for (int i = 1; i <= N; ++i)
P[i] = max(P[i - 1], A[i].ff - B[i]);
for (int i = N + 1; i > 1; --i)
S[i] = max(S[i + 1], A[i].ff - B[i - 1]);
for (int i = 1; i <= N + 1; ++i) C[A[i].ss] = max(P[i - 1], S[i + 1]);
for (int i = 1; i <= N + 1; ++i) printf("%d ", C[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... |