This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* be name khoda */
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, n) forifrom(i, 0, n)
// ------------------------------------------------------------------
const ll maxn = 200010;
ll n, A[maxn], B[maxn], lt[maxn], rt[maxn], ids[maxn], pos[maxn];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//ifstream cin("1.in");
cin >> n;
fori (i, n + 1) cin >> A[i];
fori (i, n) cin >> B[i];
iota(ids, ids + n + 1, 0);
sort(ids, ids + n + 1, [](ll a, ll b) { return A[a] < A[b]; } );
fori (i, n + 1) pos[ids[i]] = i;
sort(A, A + n + 1);
sort(B, B + n);
fori (i, n) {
lt[i + 1] = max(lt[i], A[i] - B[i]);
rt[n - i - 1] = max(rt[n - i], A[n - i] - B[n - i - 1]);
}
fori (i, n + 1) {
cout << max(lt[pos[i]], rt[pos[i]]) << ' ';
}
cout << '\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... |