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 <iostream>
#include <algorithm>
#define f first
#define s second
using namespace std;
long long n, b[200010], maxx[200010], maxxx, ans[200010];
pair<long long,int> a[200010];
int main() {
cin >> n;
for (int i = 1; i <= n+1; i++) {
cin >> a[i].f;
a[i].s = i;
}
for (int i = 1; i <= n; i++) cin >> b[i];
sort(a+1,a+n+2);
sort(b+1,b+n+1);
for (int i = n; i >= 1; i--) maxx[i] = max(maxx[i+1],a[i+1].f-b[i]);
for (int i = 1; i <= n+1; i++) {
ans[a[i].s] = max(maxxx,maxx[i]);
maxxx = max(maxxx,a[i].f-b[i]);
}
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... |