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;
int main(){
int n;
cin>>n;
int a[200005];
for(int i=0; i<n+1; i++) cin>>a[i];
int b[200005];
for(int i=0; i<n; i++) cin>>b[i];
sort(b,b+n); sort(a,a+n+1);
int eq[200005],abv[200005];
for(int i=0; i<n; i++){
eq[i] = max(a[i]-b[i],0);
abv[i] = max(a[i+1]-b[i],0);
}
int mx=0;
for(int i=0; i<n; i++) mx = max(mx, eq[i]);
vector<int> v; v.push_back(mx);
for(int i=n-1; i>=0; i--){
mx = max(mx, abv[i]);
v.push_back(mx);
}
reverse(v.begin(),v.end());
for(int i=0; i<=n; i++) cout<<v[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... |