#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+9)
#define hmod 1286031825167LL
using namespace std;
int n,b[200005],mxr[200005],mxl[200005],ans[200005];
pii a[200005];
int main(){
ios::sync_with_stdio(false);
cin >> n; n++;
for (int i=1;i<=n;i++){
cin >> a[i].x;
a[i].y=i;
}
for (int i=1;i<n;i++){
cin >> b[i];
}
sort(a+1,a+1+n); sort(b+1,b+n);
for (int i=1;i<n;i++){
mxl[i]=max(mxl[i-1],a[i].x-b[i]);
}
for (int i=2;i<=n;i++){
mxr[i]=max(0,a[i].x-b[i-1]);
}
for (int i=n-1;i>=1;i--){
mxr[i]=max(mxr[i+1],mxr[i]);
}
for (int i=1;i<=n;i++){
ans[a[i].y]=max(mxl[i-1],mxr[i+1]);
}
for (int i=1;i<=n;i++){
cout << ans[i] << " ";
}
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
492 KB |
Output is correct |
18 |
Correct |
1 ms |
492 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
1 ms |
492 KB |
Output is correct |
21 |
Correct |
1 ms |
492 KB |
Output is correct |
22 |
Correct |
2 ms |
480 KB |
Output is correct |
23 |
Correct |
1 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
2 ms |
492 KB |
Output is correct |
26 |
Correct |
1 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
492 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
492 KB |
Output is correct |
30 |
Correct |
1 ms |
452 KB |
Output is correct |
31 |
Correct |
2 ms |
484 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
492 KB |
Output is correct |
18 |
Correct |
1 ms |
492 KB |
Output is correct |
19 |
Correct |
1 ms |
492 KB |
Output is correct |
20 |
Correct |
1 ms |
492 KB |
Output is correct |
21 |
Correct |
1 ms |
492 KB |
Output is correct |
22 |
Correct |
2 ms |
480 KB |
Output is correct |
23 |
Correct |
1 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
2 ms |
492 KB |
Output is correct |
26 |
Correct |
1 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
492 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
492 KB |
Output is correct |
30 |
Correct |
1 ms |
452 KB |
Output is correct |
31 |
Correct |
2 ms |
484 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
102 ms |
10084 KB |
Output is correct |
34 |
Correct |
109 ms |
10596 KB |
Output is correct |
35 |
Correct |
126 ms |
10084 KB |
Output is correct |
36 |
Correct |
104 ms |
10596 KB |
Output is correct |
37 |
Correct |
110 ms |
10852 KB |
Output is correct |
38 |
Correct |
129 ms |
10784 KB |
Output is correct |
39 |
Correct |
102 ms |
9828 KB |
Output is correct |
40 |
Correct |
103 ms |
9828 KB |
Output is correct |
41 |
Correct |
105 ms |
9956 KB |
Output is correct |
42 |
Correct |
106 ms |
9956 KB |
Output is correct |
43 |
Correct |
101 ms |
9828 KB |
Output is correct |
44 |
Correct |
105 ms |
9440 KB |
Output is correct |
45 |
Correct |
103 ms |
9444 KB |
Output is correct |
46 |
Correct |
105 ms |
9444 KB |
Output is correct |
47 |
Correct |
108 ms |
9444 KB |
Output is correct |
48 |
Correct |
96 ms |
9444 KB |
Output is correct |
49 |
Correct |
105 ms |
10084 KB |
Output is correct |
50 |
Correct |
107 ms |
10212 KB |
Output is correct |
51 |
Correct |
109 ms |
10084 KB |
Output is correct |
52 |
Correct |
105 ms |
10080 KB |
Output is correct |
53 |
Correct |
107 ms |
10200 KB |
Output is correct |