#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l;
ll B[500005],C[500005],D[500005],ans[500005];
pair <ll,ll> A[500005];
string s[5003];
int main() {
cin>>n;
for(ll i=1;i<=n+1;i++) {
cin>>A[i].first;
A[i].second=i;
}
sort(A+1,A+1+n+1);
for(ll i=1;i<=n;i++) {
cin>>B[i];
}
sort(B+1,B+1+n);
for(ll i=1;i<=n;i++) {
C[i]=max(C[i-1],max(0ll,A[i].first-B[i]));
}
for(ll i=n;i>=1;i--) {
D[i]=max(D[i+1],max(0ll,A[i+1].first-B[i]));
//cout<<D[i]<<" ";
}
//cout<<endl;
for(ll i=1;i<=n+1;i++) {
//cout<<C[i-1]<<" "<<D[i]<<endl;
ans[A[i].second]=max(C[i-1],D[i]);
}
for(ll i=1;i<=n+1;i++) {
cout<<ans[i]<<" ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
464 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
464 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
464 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
3 ms |
520 KB |
Output is correct |
16 |
Correct |
1 ms |
460 KB |
Output is correct |
17 |
Correct |
3 ms |
588 KB |
Output is correct |
18 |
Correct |
2 ms |
588 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
3 ms |
588 KB |
Output is correct |
21 |
Correct |
2 ms |
588 KB |
Output is correct |
22 |
Correct |
2 ms |
600 KB |
Output is correct |
23 |
Correct |
2 ms |
588 KB |
Output is correct |
24 |
Correct |
2 ms |
588 KB |
Output is correct |
25 |
Correct |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
3 ms |
588 KB |
Output is correct |
27 |
Correct |
3 ms |
588 KB |
Output is correct |
28 |
Correct |
3 ms |
588 KB |
Output is correct |
29 |
Correct |
2 ms |
588 KB |
Output is correct |
30 |
Correct |
2 ms |
608 KB |
Output is correct |
31 |
Correct |
3 ms |
588 KB |
Output is correct |
32 |
Correct |
3 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
464 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
464 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
3 ms |
520 KB |
Output is correct |
16 |
Correct |
1 ms |
460 KB |
Output is correct |
17 |
Correct |
3 ms |
588 KB |
Output is correct |
18 |
Correct |
2 ms |
588 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
3 ms |
588 KB |
Output is correct |
21 |
Correct |
2 ms |
588 KB |
Output is correct |
22 |
Correct |
2 ms |
600 KB |
Output is correct |
23 |
Correct |
2 ms |
588 KB |
Output is correct |
24 |
Correct |
2 ms |
588 KB |
Output is correct |
25 |
Correct |
3 ms |
600 KB |
Output is correct |
26 |
Correct |
3 ms |
588 KB |
Output is correct |
27 |
Correct |
3 ms |
588 KB |
Output is correct |
28 |
Correct |
3 ms |
588 KB |
Output is correct |
29 |
Correct |
2 ms |
588 KB |
Output is correct |
30 |
Correct |
2 ms |
608 KB |
Output is correct |
31 |
Correct |
3 ms |
588 KB |
Output is correct |
32 |
Correct |
3 ms |
588 KB |
Output is correct |
33 |
Correct |
226 ms |
14516 KB |
Output is correct |
34 |
Correct |
230 ms |
15176 KB |
Output is correct |
35 |
Correct |
231 ms |
14760 KB |
Output is correct |
36 |
Correct |
232 ms |
15172 KB |
Output is correct |
37 |
Correct |
236 ms |
15596 KB |
Output is correct |
38 |
Correct |
229 ms |
15428 KB |
Output is correct |
39 |
Correct |
250 ms |
14540 KB |
Output is correct |
40 |
Correct |
229 ms |
14404 KB |
Output is correct |
41 |
Correct |
232 ms |
14712 KB |
Output is correct |
42 |
Correct |
228 ms |
14564 KB |
Output is correct |
43 |
Correct |
225 ms |
14404 KB |
Output is correct |
44 |
Correct |
224 ms |
14016 KB |
Output is correct |
45 |
Correct |
246 ms |
14020 KB |
Output is correct |
46 |
Correct |
223 ms |
14012 KB |
Output is correct |
47 |
Correct |
223 ms |
14256 KB |
Output is correct |
48 |
Correct |
225 ms |
14272 KB |
Output is correct |
49 |
Correct |
241 ms |
14928 KB |
Output is correct |
50 |
Correct |
235 ms |
14916 KB |
Output is correct |
51 |
Correct |
234 ms |
14868 KB |
Output is correct |
52 |
Correct |
259 ms |
14888 KB |
Output is correct |
53 |
Correct |
229 ms |
14800 KB |
Output is correct |