#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=2e5+10, MAXV=2e9+10;
int n, b[MAX], maxil[MAX], maxip[MAX], wynik[MAX];
pair<int,int>a[MAX];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin>>n;
for(int i=1; i<=n+1; i++){
cin>>a[i].fi;
a[i].se=i;
}
for(int i=1; i<=n; i++)
cin>>b[i];
sort(a+1, a+n+2);
sort(b+1, b+n+1);
for(int i=1; i<=n; i++)
maxil[i]=max(maxil[i-1], max(0, a[i].fi-b[i]));
for(int i=n+1; i>=2; i--)
maxip[i]=max(maxip[i+1], max(0, a[i].fi-b[i-1]));
for(int i=1; i<=n+1; i++)
wynik[a[i].se]=max(maxil[i-1], maxip[i+1]);
for(int i=1; i<=n+1; i++)
cout<<wynik[i]<<" ";
cout<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
480 KB |
Output is correct |
15 |
Correct |
2 ms |
388 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
368 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
368 KB |
Output is correct |
23 |
Correct |
2 ms |
356 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
372 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
480 KB |
Output is correct |
15 |
Correct |
2 ms |
388 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
368 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
368 KB |
Output is correct |
23 |
Correct |
2 ms |
356 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
372 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
87 ms |
9924 KB |
Output is correct |
34 |
Correct |
88 ms |
10352 KB |
Output is correct |
35 |
Correct |
84 ms |
10044 KB |
Output is correct |
36 |
Correct |
87 ms |
10548 KB |
Output is correct |
37 |
Correct |
90 ms |
10856 KB |
Output is correct |
38 |
Correct |
88 ms |
10684 KB |
Output is correct |
39 |
Correct |
87 ms |
9828 KB |
Output is correct |
40 |
Correct |
86 ms |
9720 KB |
Output is correct |
41 |
Correct |
85 ms |
9816 KB |
Output is correct |
42 |
Correct |
96 ms |
9780 KB |
Output is correct |
43 |
Correct |
97 ms |
9672 KB |
Output is correct |
44 |
Correct |
83 ms |
9292 KB |
Output is correct |
45 |
Correct |
83 ms |
9344 KB |
Output is correct |
46 |
Correct |
91 ms |
9304 KB |
Output is correct |
47 |
Correct |
82 ms |
9376 KB |
Output is correct |
48 |
Correct |
81 ms |
9436 KB |
Output is correct |
49 |
Correct |
88 ms |
9992 KB |
Output is correct |
50 |
Correct |
94 ms |
10064 KB |
Output is correct |
51 |
Correct |
92 ms |
10060 KB |
Output is correct |
52 |
Correct |
95 ms |
9992 KB |
Output is correct |
53 |
Correct |
90 ms |
10064 KB |
Output is correct |