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 <fstream>
#include <climits>
#include <cstring>
#include <algorithm>
using namespace std;
const int nmax=2e5+5;
int n, v[nmax], b[nmax], rez[nmax];
struct tie
{
int poz, val;
} v1[nmax];
bool compare (tie a, tie b)
{
return a.val<b.val;
}
int main()
{
cin >> n;
for (int i=1;i<=n+1;i++)
{
cin >> v[i];
v1[i]={i, v[i]};
}
for (int i=1;i<=n;i++)
{
cin >> b[i];
}
sort (b+1, b+n+1);
sort (v1+1, v1+n+2, compare);
int mx=0;
for (int i=1;i<=n;i++)
{
mx=max (mx, max (0, v1[i].val-b[i]));
}
rez[v1[n+1].poz]=mx;
for (int i=n;i>=1;i--)
{
mx=max (mx, max (0, v1[i+1].val-b[i]));
rez[v1[i].poz]=mx;
}
for (int i=1;i<=n+1;i++)
{
cout << rez[i] << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |