#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,a;
cin >> n;
vector<int> ans(n+1);
vector<pair<int,int>> haha(n+1);
vector<int> bruh(n);
for(int i = 0; i <= n; i++) {
cin >> a;
haha[i] = {a,i};
}
for(int i = 0; i < n; i++) {
cin >> bruh[i];
}
sort(haha.begin(),haha.end());
sort(bruh.begin(),bruh.end());
vector<int> pr(n+1);
vector<int> su(n+1);
for(int i = 1; i <= n; i++) {
pr[i] = abs(haha[i-1].first-bruh[i-1]);
pr[i] = max(pr[i],pr[i-1]);
}
for(int i = n-1; i >= 0; i--) {
su[i] = abs(haha[i+1].first-bruh[i]);
su[i] = max(su[i],su[i+1]);
}
for(int i = 0; i < n+1; i++) {
ans[haha[i].second] = max(pr[i],su[i]);
}
for(int i = 0; i < n+1; i++) {
cout << ans[i] << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |