# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202625 | SamAnd | Just Long Neckties (JOI20_ho_t1) | C++17 | 145 ms | 7032 KiB |
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;
const int N = 200005;
struct ban
{
int x, i;
};
bool operator<(const ban& a, const ban& b)
{
return a.x < b.x;
}
int n;
ban a[N];
int b[N];
int p[N], s[N];
int ans[N];
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n + 1; ++i)
{
a[i].i = i;
scanf("%d", &a[i].x);
}
for (int i = 1; i <= n; ++i)
scanf("%d", &b[i]);
sort(a + 1, a + n + 1 + 1);
sort(b + 1, b + n + 1);
for (int i = 1; i <= n; ++i)
{
p[i] = max(p[i - 1], a[i].x - b[i]);
}
for (int i = n + 1; i >= 2; --i)
{
s[i] = max(s[i + 1], a[i].x - b[i - 1]);
}
for (int i = 1; i <= n + 1; ++i)
ans[a[i].i] = max(p[i - 1], s[i + 1]);
for (int i = 1; i <= n + 1; ++i)
printf("%d ", ans[i]);
printf("\n");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |