#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, b[N], p[N], s[N], ans[N];
pair<int, int> a[N];
int main(){
cin >> n;
for(int i =0;i < n + 1; i++){
cin >> a[i].first;
a[i].second = i;
}
for(int i = 0; i < n; i++){
cin >> b[i];
}
sort(a , a + n + 1);
sort(b, b + n);
for(int i =0 ; i < n; i++){
p[i] = max(a[i].first - b[i], 0);
if(i) p[i] = max(p[i], p[i-1]);
}
for(int i = n; i > 0; i--){
s[i] = max(s[i + 1], max(a[i].first - b[i-1], 0));
}
for(int i =0 ; i <= n; i++){
ans[a[i].second] = s[i + 1];
if(i >= 1 ){
ans[a[i].second] = max(ans[a[i].second], p[i-1]);
}
}
for(int i =0; i <= n; i++){
cout << ans[i] << " "[i == n];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |