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;
#define int long long
int A[200005], B[200005], ans[200005];
pair<int, int> X[200005];
main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;
cin >> n;
for(int i=1;i<=n+1;i++)cin >> A[i], X[i] = make_pair(A[i], i);
for(int i=1;i<=n;i++)cin >> B[i];
sort(X+1, X+n+2);
sort(B+1, B+n+1);
int cnt = 0;
for(int i=1;i<=n;i++)cnt = max(cnt, X[i].first - B[i]);
for(int i=n+1;i>=1;i--){
if(i == n + 1)ans[X[i].second] = cnt;
else{
cnt = max(cnt, X[i+1].first - B[i]);
ans[X[i].second] = cnt;
}
}
for(int i=1;i<=n+1;i++)cout << ans[i] << " ";
}
Compilation message (stderr)
ho_t1.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |