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;
typedef pair<int, int> pii;
int n;
pii A[200001];
int B[200001];
int L[200002];
int R[200002];
int ans[200001];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for (int i = 0; i <= n; ++i) {
cin >> A[i].first;
A[i].second = i;
}
for (int i = 1; i <= n; ++i) cin >> B[i];
sort(A, A + (n + 1));
sort(B + 1, B + (n + 1));
for (int i = 1; i <= n; ++i) L[i] = max(L[i - 1], A[i - 1].first - B[i]);
for (int i = n; i > 0; --i) R[i] = max(R[i + 1], A[i].first - B[i]);
for (int i = 0; i <= n; ++i) ans[A[i].second] = max(L[i], R[i + 1]);
for (int i = 0; i <= n; ++i) printf("%d%c", ans[i], "\n "[i < n]);
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... |