이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(0); std::cin.tie(0);
int n; std::cin >> n;
std::vector <int> b(n), ans(n + 1);
std::vector <std::pair <int, int>> a(n + 1);
for (int i = 0; i <= n; i++) std::cin >> a[i].first, a[i].second = i;
for (int& x : b) std::cin >> x;
std::sort(a.begin(), a.end());
std::sort(b.begin(), b.end());
for (int i = 0, max = 0; i < n; i++) {
max = std::max(max, a[i].first - b[i]);
ans[a[i + 1].second] = std::max(ans[a[i + 1].second], max);
}
for (int i = n, max = 0; i > 0; i--) {
max = std::max(max, a[i].first - b[i - 1]);
ans[a[i - 1].second] = std::max(ans[a[i - 1].second], max);
}
for (int i = 0; i <= n; i++) std::cout << ans[i] << " \n"[i == n];
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |