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;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b); i-- > (a); )
const int N = 1 << 18;
pair<int, int> a[N];
int b[N], c[N], p[N], s[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
rep(i, 0, n + 1) {
int x; cin >> x;
a[i] = {x, i};
}
rep(i, 0, n) cin >> b[i];
sort(a, a + n + 1); sort(b, b + n);
rep(i, 0, n) p[i + 1] = max(p[i], a[i].first - b[i]);
per(i, 0, n) s[i] = max(s[i + 1], a[i + 1].first - b[i]);
rep(i, 0, n + 1) c[a[i].second] = max(p[i], s[i]);
rep(i, 0, n + 1) cout << c[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... |