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>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int main(){
int n; cin >> n;
int a[n + 2];
for(int i = 1; i <= n + 1; i++){
cin >> a[i];
}
sort(a + 1, a + 2 + n);
int b[n + 1];
for(int i = 1; i <= n; i++) cin >> b[i];
sort(b + 1, b + 1 + n);
int pref[n + 1];
int suf[n + 3];
pref[0] = 0;
suf[n + 2] = 0;
for(int i = 1; i <= n; i++){
pref[i] = max(pref[i - 1], a[i] - b[i]);
}
for(int i = n + 1; i >= 2; i--){
suf[i] = max(suf[i + 1], a[i] - b[i - 1]);
}
for(int i = 1; i <= n + 1; i++){
cout << max(pref[i - 1], suf[i + 1]) << " ";
}
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... |