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;
const int k_N = 2e5 + 3;
int n;
int a[k_N], b[k_N];
int prefix[k_N], suffix[k_N];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n + 1; ++i)
cin >> a[i];
for(int i = 1; i <= n; ++i)
cin >> b[i];
sort(a + 1, a + 1 + n + 1);
sort(b + 1, b + 1 + n);
for(int i = 1; i <= n; ++i)
prefix[i] = max(prefix[i - 1], max(a[i] - b[i], 0));
for(int i = n + 1; i >= 2; --i)
suffix[i] = max(suffix[i + 1], max(a[i] - b[i - 1], 0));
for(int i = 1; i <= n; ++i)
cout << max(prefix[i - 1], suffix[i + 1]) << " ";
cout << prefix[n] << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |