#include <bits/stdc++.h>
//#define int long long
#define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
using namespace std;
int main(){
int n;
//fastio
cin >> n;
vector<int> a(n+1), b(n), m1(n+1), m2(n+1);
for(int i=0; i<=n; i++) cin >> a[i];
for(int i=0; i<n; i++) cin >> b[i];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
m1[0] = max(a[0]-b[0], 0);
m2[n-1] = max(a[n]-b[n-1], 0);
for(int i=1; i<n; i++)
m1[i] = max(m1[i-1], a[i]-b[i]);
for(int i=n-2; i>-1; i--)
m2[i] = max(m2[i+1], a[i+1]-b[i]);
cout << m2[0] << ' ';
for(int i=1; i<n; i++)
cout << max(m2[i], m1[i-1]) << ' ';
cout << m1[n-1] << ' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |