이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
typedef long long llong;
const int MAXN = 200000 + 10;
const llong INF = 1e18;
int n;
int a[MAXN];
int b[MAXN];
llong prefix[MAXN];
llong suffix[MAXN];
void solve()
{
std::sort(a + 1, a + 2 + n);
std::sort(b + 1, b + 1 + n);
for (int i = 1 ; i <= n ; ++i)
{
prefix[i] = std::max(prefix[i - 1], 1LL * std::max(0, a[i] - b[i]));
}
for (int i = n ; i >= 1 ; --i)
{
suffix[i] = std::max(suffix[i + 1], 1LL * std::max(0, a[i+1] - b[i]));
}
for (int i = 1 ; i <= n + 1 ; ++i)
{
std::cout << std::max(prefix[i - 1], suffix[i]) << ' ';
}
std::cout << '\n';
}
void read()
{
std::cin >> n;
for (int i = 1 ; i <= n + 1 ; ++i) std::cin >> a[i];
for (int i = 1 ; i <= n ; ++i) std::cin >> b[i];
}
void fastIO()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIO();
read();
solve();
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... |