#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ll n, b[(int)2e5+5], c1[(int)2e5+5], c2[(int)2e5+5], ans[(int)2e5+5];
pair <ll, ll> c[(int)2e5+5], a[(int)2e5+5];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
for(int i = 1; i <= n+1; i++){
cin>>a[i].f;
a[i].s = i;
}
for(int i = 1; i <= n; i++) cin>>b[i];
sort(a+1, a+n+2); sort(b+1, b+n+1);
c1[0] = -1e18; c2[n+1] = -1e18;
for(int i = 1; i <= n; i++){
c[i].f = max(0ll, a[i].f-b[i]);
c[i].s = max(0ll, a[i+1].f-b[i]);
c1[i] = max(c1[i-1], c[i].f);
}
for(int i = n; i >= 1; i--){
c2[i] = max(c2[i+1], c[i].s);
}
for(int i = 1; i <= n+1; i++){
ans[a[i].s] = max(c1[i-1], c2[i]);
}
for(int i = 1; i <= n+1; i++){
cout<<ans[i]<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10588 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
2 ms |
10588 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
2 ms |
10588 KB |
Output is correct |
9 |
Correct |
3 ms |
10588 KB |
Output is correct |
10 |
Correct |
2 ms |
10588 KB |
Output is correct |
11 |
Correct |
2 ms |
10588 KB |
Output is correct |
12 |
Correct |
2 ms |
10840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10588 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
2 ms |
10588 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
2 ms |
10588 KB |
Output is correct |
9 |
Correct |
3 ms |
10588 KB |
Output is correct |
10 |
Correct |
2 ms |
10588 KB |
Output is correct |
11 |
Correct |
2 ms |
10588 KB |
Output is correct |
12 |
Correct |
2 ms |
10840 KB |
Output is correct |
13 |
Correct |
3 ms |
10588 KB |
Output is correct |
14 |
Correct |
2 ms |
10736 KB |
Output is correct |
15 |
Correct |
3 ms |
10588 KB |
Output is correct |
16 |
Correct |
2 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
3 ms |
10588 KB |
Output is correct |
20 |
Correct |
3 ms |
10588 KB |
Output is correct |
21 |
Correct |
3 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
3 ms |
10588 KB |
Output is correct |
24 |
Correct |
3 ms |
10588 KB |
Output is correct |
25 |
Correct |
2 ms |
10588 KB |
Output is correct |
26 |
Correct |
3 ms |
10588 KB |
Output is correct |
27 |
Correct |
3 ms |
10584 KB |
Output is correct |
28 |
Correct |
4 ms |
10584 KB |
Output is correct |
29 |
Correct |
3 ms |
10588 KB |
Output is correct |
30 |
Correct |
3 ms |
10588 KB |
Output is correct |
31 |
Correct |
3 ms |
10588 KB |
Output is correct |
32 |
Correct |
3 ms |
10584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10588 KB |
Output is correct |
5 |
Correct |
3 ms |
10588 KB |
Output is correct |
6 |
Correct |
2 ms |
10588 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
2 ms |
10588 KB |
Output is correct |
9 |
Correct |
3 ms |
10588 KB |
Output is correct |
10 |
Correct |
2 ms |
10588 KB |
Output is correct |
11 |
Correct |
2 ms |
10588 KB |
Output is correct |
12 |
Correct |
2 ms |
10840 KB |
Output is correct |
13 |
Correct |
3 ms |
10588 KB |
Output is correct |
14 |
Correct |
2 ms |
10736 KB |
Output is correct |
15 |
Correct |
3 ms |
10588 KB |
Output is correct |
16 |
Correct |
2 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
3 ms |
10588 KB |
Output is correct |
20 |
Correct |
3 ms |
10588 KB |
Output is correct |
21 |
Correct |
3 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
3 ms |
10588 KB |
Output is correct |
24 |
Correct |
3 ms |
10588 KB |
Output is correct |
25 |
Correct |
2 ms |
10588 KB |
Output is correct |
26 |
Correct |
3 ms |
10588 KB |
Output is correct |
27 |
Correct |
3 ms |
10584 KB |
Output is correct |
28 |
Correct |
4 ms |
10584 KB |
Output is correct |
29 |
Correct |
3 ms |
10588 KB |
Output is correct |
30 |
Correct |
3 ms |
10588 KB |
Output is correct |
31 |
Correct |
3 ms |
10588 KB |
Output is correct |
32 |
Correct |
3 ms |
10584 KB |
Output is correct |
33 |
Correct |
72 ms |
16576 KB |
Output is correct |
34 |
Correct |
70 ms |
16464 KB |
Output is correct |
35 |
Correct |
68 ms |
16464 KB |
Output is correct |
36 |
Correct |
75 ms |
16756 KB |
Output is correct |
37 |
Correct |
72 ms |
17236 KB |
Output is correct |
38 |
Correct |
71 ms |
16768 KB |
Output is correct |
39 |
Correct |
71 ms |
15956 KB |
Output is correct |
40 |
Correct |
69 ms |
15952 KB |
Output is correct |
41 |
Correct |
69 ms |
15996 KB |
Output is correct |
42 |
Correct |
72 ms |
16052 KB |
Output is correct |
43 |
Correct |
69 ms |
16000 KB |
Output is correct |
44 |
Correct |
67 ms |
15696 KB |
Output is correct |
45 |
Correct |
68 ms |
15736 KB |
Output is correct |
46 |
Correct |
68 ms |
15696 KB |
Output is correct |
47 |
Correct |
64 ms |
15700 KB |
Output is correct |
48 |
Correct |
66 ms |
15700 KB |
Output is correct |
49 |
Correct |
73 ms |
16208 KB |
Output is correct |
50 |
Correct |
71 ms |
16208 KB |
Output is correct |
51 |
Correct |
72 ms |
16212 KB |
Output is correct |
52 |
Correct |
71 ms |
16212 KB |
Output is correct |
53 |
Correct |
72 ms |
16212 KB |
Output is correct |