#include <bits/stdc++.h>
#include <bits/extc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
using namespace std;
//limit definitions
#define N 200050
int b[N], p[N], s[N], ans[N];
pair<int, int> a[N];
signed main(){
int n; cin >> n;
for(int i = 1; i < n + 2; i++) cin >> a[i].ff, a[i].ss = i;
for(int i = 1; i < n + 1; i++) cin >> b[i];
sort(a, a + n + 2), sort(b, b + n + 1);
for(int i = 1; i < n + 1; i++) p[i] = max(p[i - 1], a[i].ff - b[i]);
for(int i = n; i > 0; i--) s[i] = max(s[i + 1], a[i + 1].ff - b[i]);
for(int i = 0; i < n + 1; i++) ans[a[i + 1].ss] = max(p[i], s[i + 1]);
for(int i = 1; i < n + 2; i++) cout << ans[i] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
320 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
308 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
452 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
320 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
308 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
452 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
145 ms |
14344 KB |
Output is correct |
34 |
Correct |
152 ms |
14972 KB |
Output is correct |
35 |
Correct |
146 ms |
14536 KB |
Output is correct |
36 |
Correct |
148 ms |
14980 KB |
Output is correct |
37 |
Correct |
152 ms |
15488 KB |
Output is correct |
38 |
Correct |
151 ms |
15236 KB |
Output is correct |
39 |
Correct |
149 ms |
14340 KB |
Output is correct |
40 |
Correct |
154 ms |
14412 KB |
Output is correct |
41 |
Correct |
148 ms |
14360 KB |
Output is correct |
42 |
Correct |
148 ms |
14328 KB |
Output is correct |
43 |
Correct |
149 ms |
14268 KB |
Output is correct |
44 |
Correct |
147 ms |
13820 KB |
Output is correct |
45 |
Correct |
146 ms |
13892 KB |
Output is correct |
46 |
Correct |
144 ms |
13824 KB |
Output is correct |
47 |
Correct |
178 ms |
14080 KB |
Output is correct |
48 |
Correct |
146 ms |
14132 KB |
Output is correct |
49 |
Correct |
153 ms |
14696 KB |
Output is correct |
50 |
Correct |
158 ms |
14668 KB |
Output is correct |
51 |
Correct |
153 ms |
14664 KB |
Output is correct |
52 |
Correct |
150 ms |
14616 KB |
Output is correct |
53 |
Correct |
156 ms |
14620 KB |
Output is correct |