#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N;
pair<ll, ll> A[200005];
ll B[200005], R[200005];
ll P[200005], S[200005];
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N;
for(ll i = 1; i <= N + 1; i++){
cin >> A[i].first;
A[i].second = i;
}
for(ll i = 1; i <= N; i++){
cin >> B[i];
}
sort(A + 1, A + N + 2);
sort(B + 1, B + N + 1);
for(ll i = 1; i <= N; i++){
P[i] = max(P[i - 1], A[i].first - B[i]);
}
for(ll i = N; i >= 1; i--){
S[i] = max(S[i + 1], A[i + 1].first - B[i]);
}
for(ll i = 1; i <= N + 1; i++){
R[A[i].second] = max(P[i - 1], S[i]);
}
for(ll i = 1; i <= N + 1; i++){
cout << R[i] << ' ';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
464 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
2 ms |
480 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
388 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
480 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 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 |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
464 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
2 ms |
480 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
388 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
480 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
133 ms |
14352 KB |
Output is correct |
34 |
Correct |
97 ms |
14992 KB |
Output is correct |
35 |
Correct |
97 ms |
14516 KB |
Output is correct |
36 |
Correct |
115 ms |
15044 KB |
Output is correct |
37 |
Correct |
107 ms |
15504 KB |
Output is correct |
38 |
Correct |
108 ms |
15228 KB |
Output is correct |
39 |
Correct |
121 ms |
14276 KB |
Output is correct |
40 |
Correct |
92 ms |
14300 KB |
Output is correct |
41 |
Correct |
93 ms |
14340 KB |
Output is correct |
42 |
Correct |
102 ms |
14344 KB |
Output is correct |
43 |
Correct |
96 ms |
14236 KB |
Output is correct |
44 |
Correct |
86 ms |
13836 KB |
Output is correct |
45 |
Correct |
102 ms |
13836 KB |
Output is correct |
46 |
Correct |
96 ms |
13828 KB |
Output is correct |
47 |
Correct |
86 ms |
14084 KB |
Output is correct |
48 |
Correct |
91 ms |
14060 KB |
Output is correct |
49 |
Correct |
93 ms |
14628 KB |
Output is correct |
50 |
Correct |
118 ms |
14632 KB |
Output is correct |
51 |
Correct |
100 ms |
14632 KB |
Output is correct |
52 |
Correct |
93 ms |
14720 KB |
Output is correct |
53 |
Correct |
102 ms |
14628 KB |
Output is correct |