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 <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl
#define MAX 200000
#define val first
#define pos second
lli n,paso,a,act;
lli res[MAX+2],B[MAX+2],maximos[MAX+2];
pair<lli,lli> A[MAX+2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
rep(i,1,n+1) {
cin >> A[i].val;
A[i].pos = i;;
}
rep(i,1,n) cin >> B[i];
sort(A+1, A+2+n);
sort(B+1,B+n+1);
rep(i,1,n) {
a = max(A[i].val - B[i], 0ll);
maximos[i] = max(a,maximos[i-1]);
}
res[A[n+1].pos] = maximos[n];
act = 0;
repa(i,n,1) {
a = max(A[i+1].val - B[i], 0ll);
act = max(act,a);
res[A[i].pos] = max(act,maximos[i-1]);
}
rep(i,1,n+1) cout << res[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... |