이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
int n;
int prefix[200005], suffix[200005], ans[200005];
std::pair <int, int> a[200005];
int b[200005];
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
std::cin >> n;
for(int i = 1; i <= n + 1; i++)
{
std::cin >> a[i].first;
a[i].second = i;
}
std::sort(a + 1, a + n + 2);
for(int i = 1; i <= n; i++)
{
std::cin >> b[i];
}
std::sort(b + 1, b + n + 1);
for(int i = 1; i <= n; i++)
{
prefix[i] = std::max(prefix[i - 1], a[i].first - b[i]);
}
for(int i = n + 1; i >= 2; i--)
{
suffix[i] = std::max(suffix[i + 1], a[i].first - b[i - 1]);
}
for(int i = 1; i <= n + 1; i++)
{
ans[a[i].second] = std::max(prefix[i - 1], suffix[i + 1]);
}
for(int i = 1; i <= n + 1; i++)
{
std::cout << ans[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... |