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;
pair<int, int> neckties[200'005];
int employees[200'005];
int strangeness[200'005];
int ans[200'005];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
for (int i = 0; i <= n; i++)
{
cin >> neckties[i].first;
neckties[i].second = i;
}
for (int i = 0; i < n; i++)
{
cin >> employees[i];
}
sort (neckties, neckties + n + 1);
sort (employees, employees + n);
for (int i = n+1; i > 0; i--)
{
strangeness[i] = max(strangeness[i+1], neckties[i].first - employees[i-1]);
}
int str = 0;
for (int i = 0; i <= n; i++)
{
ans[neckties[i].second] = max (str, strangeness[i+1]);
str = max(str, neckties[i].first - employees[i]);
}
for (int i = 0; i <= n; 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... |