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;
int n, maxi = 0, b[100001], ans[100001];
pair<int, int> a[100001];
int main()
{
cin >> n;
for(int i = 1; i <= n + 1; ++i)
{
cin >> a[i].first;
a[i].second = 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 = 1; i <= n; ++i)
{
maxi = max(maxi, max(a[i].first - b[i], 0));
}
ans[a[n + 1].second] = maxi;
for(int i = n; i >= 1; --i)
{
maxi = max(maxi, max(a[i + 1].first - b[i], 0));
ans[a[i].second] = maxi;
}
for(int i = 1; i <= n + 1; ++i) cout << ans[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... |