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>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " " << (x) << endl;
#define V vector
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
V<pi> a(n+2);
for(int i = 1; i <= n + 1; i++) {
cin >> a[i].F;
a[i].S = i;
}
sort(ALL(a));
vi b(n+1), l(n+3), r(n+3), ans(n+2);
for(int i = 1; i <= n; i++) cin >> b[i];
sort(ALL(b));
for(int i = 1; i <= n + 1; i++) l[i] = max(l[i-1], a[i].F-b[i]);
for(int i = n + 1; i >= 2; i--) r[i] = max(r[i+1], a[i].F-b[i-1]);
for(int i = 1; i <= n + 1; i++) {
ans[a[i].S] = max(l[i-1], r[i+1]);
}
for(int i = 1; i <= n + 1; i++) cout << ans[i] << " ";
cout << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |