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>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
int main()
{
int n;
cin >> n;
long long mx = 0;
pair<long long, int> a[n+1];
long long b[n], ans[n+1], cur[n];
for(int i = 0; i < n+1; i++)
{
cin >> a[i].first;
a[i].second = i;
}
for(int i = 0; i < n; i++)
{
cin >> b[i];
}
sort(a,a+n+1);
sort(b,b+n);
for(int i = n-1; i >= 0; i--)
{
cur[i] = max(a[i].first-b[i],0ll);
mx = max(mx,cur[i]);
}
ans[a[n].second] = mx;
for(int i = n-1; i >= 0; i--)
{
cur[i] = max(a[i+1].first-b[i],0ll);
mx = max(mx,cur[i]);
ans[a[i].second] = mx;
}
for(int i = 0; i < n+1; i++)
{
cout << ans[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... |