이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |