#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,b[200005];
pair<int,int> a[200005];
int ans[200005];
int d1[200005],d2[200005];
int maxpref[200005],maxsuf[200005];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 1; i <= n + 1; i++)
cin >> a[i].first,a[i].second = i;
for (int i = 1; i <= n; i++)
cin >> b[i];
sort(b + 1,b + n + 1);
sort(a + 1,a + n + 2);
for (int i = 1; i <= n; i++)
d1[i] = abs(a[i].first - b[i]);
for (int i = 1; i <= n; i++)
d2[i] = abs(a[i + 1].first - b[i]);
maxpref[0] = 0;
maxsuf[n + 1] = 0;
for (int i = 1; i <= n; i++)
maxpref[i] = max(maxpref[i - 1],abs(a[i].first - b[i]));
for (int i = n; i >= 1; i--)
maxsuf[i] = max(maxsuf[i + 1],abs(a[i + 1].first - b[i]));
for (int i = 1; i <= n + 1; i++)
ans[a[i].second] = max(maxpref[i - 1],maxsuf[i]);
for (int i = 1; i <= n + 1; i++)
cout << ans[i] << ' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |