#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ar array
const int LOG = 20;
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 3e5 + 20;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,avx,bmi,bmi2")
int a[N], A[N], B[N], pref[N], suff[N];
int n;
signed main(){ios_base::sync_with_stdio(false);
cin>>n;
for(int i = 1;i <= n + 1;i++)cin>>a[i], A[i] = a[i];
for(int i = 1;i <= n;i++)cin>>B[i];
sort(A + 1, A + n + 2);
sort(B + 1, B + n + 1);
//assert(0);
for(int i = 1;i <= n;i++)pref[i] = max(pref[i - 1], A[i] - B[i]);
for(int i = n;i > 1;i--)suff[i] = max(suff[i + 1], A[i] - B[i - 1]);
map<int,int> ans;
for(int i =1;i <= n + 1;i++)ans[A[i]] = max(pref[i - 1], suff[i + 1]);
for(int i = 1 ;i <= n + 1;i++)cout<<ans[a[i]]<<" ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Incorrect |
1 ms |
6488 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Incorrect |
1 ms |
6488 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Incorrect |
1 ms |
6488 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |