#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
pair<int,int> a[200005];
for(int i=0; i<n+1; i++){ cin>>a[i].first; a[i].second = i;}
int b[200005];
for(int i=0; i<n; i++) cin>>b[i];
sort(b,b+n); sort(a,a+n+1);
int eq[200005],abv[200005];
for(int i=0; i<n; i++){
eq[i] = max(a[i].first-b[i],0);
abv[i] = max(a[i+1].first-b[i],0);
}
int ans[200005];
int mx=0;
for(int i=0; i<n; i++) mx = max(mx, eq[i]);
ans[a[n].second] = mx;
for(int i=n-1; i>=0; i--){
mx = max(mx, abv[i]);
ans[a[i].second] = mx;
}
for(int i=0; i<=n; i++) cout<<ans[i]<<' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1920 KB |
Output is correct |
2 |
Correct |
5 ms |
1920 KB |
Output is correct |
3 |
Correct |
5 ms |
1920 KB |
Output is correct |
4 |
Correct |
5 ms |
1920 KB |
Output is correct |
5 |
Correct |
5 ms |
1920 KB |
Output is correct |
6 |
Correct |
5 ms |
1920 KB |
Output is correct |
7 |
Correct |
5 ms |
1920 KB |
Output is correct |
8 |
Correct |
6 ms |
1920 KB |
Output is correct |
9 |
Correct |
6 ms |
1920 KB |
Output is correct |
10 |
Correct |
5 ms |
1920 KB |
Output is correct |
11 |
Correct |
5 ms |
1920 KB |
Output is correct |
12 |
Correct |
5 ms |
1920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1920 KB |
Output is correct |
2 |
Correct |
5 ms |
1920 KB |
Output is correct |
3 |
Correct |
5 ms |
1920 KB |
Output is correct |
4 |
Correct |
5 ms |
1920 KB |
Output is correct |
5 |
Correct |
5 ms |
1920 KB |
Output is correct |
6 |
Correct |
5 ms |
1920 KB |
Output is correct |
7 |
Correct |
5 ms |
1920 KB |
Output is correct |
8 |
Correct |
6 ms |
1920 KB |
Output is correct |
9 |
Correct |
6 ms |
1920 KB |
Output is correct |
10 |
Correct |
5 ms |
1920 KB |
Output is correct |
11 |
Correct |
5 ms |
1920 KB |
Output is correct |
12 |
Correct |
5 ms |
1920 KB |
Output is correct |
13 |
Correct |
6 ms |
1920 KB |
Output is correct |
14 |
Correct |
7 ms |
1920 KB |
Output is correct |
15 |
Correct |
7 ms |
2048 KB |
Output is correct |
16 |
Correct |
5 ms |
1920 KB |
Output is correct |
17 |
Correct |
8 ms |
2048 KB |
Output is correct |
18 |
Correct |
7 ms |
2048 KB |
Output is correct |
19 |
Correct |
8 ms |
2048 KB |
Output is correct |
20 |
Correct |
8 ms |
2048 KB |
Output is correct |
21 |
Correct |
8 ms |
1920 KB |
Output is correct |
22 |
Correct |
8 ms |
2048 KB |
Output is correct |
23 |
Correct |
8 ms |
2100 KB |
Output is correct |
24 |
Correct |
8 ms |
1920 KB |
Output is correct |
25 |
Correct |
8 ms |
2048 KB |
Output is correct |
26 |
Correct |
8 ms |
2048 KB |
Output is correct |
27 |
Correct |
8 ms |
2048 KB |
Output is correct |
28 |
Correct |
8 ms |
1920 KB |
Output is correct |
29 |
Correct |
8 ms |
2048 KB |
Output is correct |
30 |
Correct |
8 ms |
2048 KB |
Output is correct |
31 |
Correct |
8 ms |
1920 KB |
Output is correct |
32 |
Correct |
8 ms |
1920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1920 KB |
Output is correct |
2 |
Correct |
5 ms |
1920 KB |
Output is correct |
3 |
Correct |
5 ms |
1920 KB |
Output is correct |
4 |
Correct |
5 ms |
1920 KB |
Output is correct |
5 |
Correct |
5 ms |
1920 KB |
Output is correct |
6 |
Correct |
5 ms |
1920 KB |
Output is correct |
7 |
Correct |
5 ms |
1920 KB |
Output is correct |
8 |
Correct |
6 ms |
1920 KB |
Output is correct |
9 |
Correct |
6 ms |
1920 KB |
Output is correct |
10 |
Correct |
5 ms |
1920 KB |
Output is correct |
11 |
Correct |
5 ms |
1920 KB |
Output is correct |
12 |
Correct |
5 ms |
1920 KB |
Output is correct |
13 |
Correct |
6 ms |
1920 KB |
Output is correct |
14 |
Correct |
7 ms |
1920 KB |
Output is correct |
15 |
Correct |
7 ms |
2048 KB |
Output is correct |
16 |
Correct |
5 ms |
1920 KB |
Output is correct |
17 |
Correct |
8 ms |
2048 KB |
Output is correct |
18 |
Correct |
7 ms |
2048 KB |
Output is correct |
19 |
Correct |
8 ms |
2048 KB |
Output is correct |
20 |
Correct |
8 ms |
2048 KB |
Output is correct |
21 |
Correct |
8 ms |
1920 KB |
Output is correct |
22 |
Correct |
8 ms |
2048 KB |
Output is correct |
23 |
Correct |
8 ms |
2100 KB |
Output is correct |
24 |
Correct |
8 ms |
1920 KB |
Output is correct |
25 |
Correct |
8 ms |
2048 KB |
Output is correct |
26 |
Correct |
8 ms |
2048 KB |
Output is correct |
27 |
Correct |
8 ms |
2048 KB |
Output is correct |
28 |
Correct |
8 ms |
1920 KB |
Output is correct |
29 |
Correct |
8 ms |
2048 KB |
Output is correct |
30 |
Correct |
8 ms |
2048 KB |
Output is correct |
31 |
Correct |
8 ms |
1920 KB |
Output is correct |
32 |
Correct |
8 ms |
1920 KB |
Output is correct |
33 |
Correct |
284 ms |
10076 KB |
Output is correct |
34 |
Correct |
308 ms |
10468 KB |
Output is correct |
35 |
Correct |
293 ms |
10104 KB |
Output is correct |
36 |
Correct |
293 ms |
10620 KB |
Output is correct |
37 |
Correct |
301 ms |
10872 KB |
Output is correct |
38 |
Correct |
298 ms |
10744 KB |
Output is correct |
39 |
Correct |
288 ms |
9848 KB |
Output is correct |
40 |
Correct |
295 ms |
9848 KB |
Output is correct |
41 |
Correct |
295 ms |
9848 KB |
Output is correct |
42 |
Correct |
294 ms |
9976 KB |
Output is correct |
43 |
Correct |
290 ms |
9848 KB |
Output is correct |
44 |
Correct |
287 ms |
9464 KB |
Output is correct |
45 |
Correct |
288 ms |
9464 KB |
Output is correct |
46 |
Correct |
286 ms |
9464 KB |
Output is correct |
47 |
Correct |
298 ms |
9464 KB |
Output is correct |
48 |
Correct |
293 ms |
9464 KB |
Output is correct |
49 |
Correct |
315 ms |
10108 KB |
Output is correct |
50 |
Correct |
304 ms |
10104 KB |
Output is correct |
51 |
Correct |
310 ms |
10232 KB |
Output is correct |
52 |
Correct |
293 ms |
10104 KB |
Output is correct |
53 |
Correct |
305 ms |
10104 KB |
Output is correct |