#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
const int N = 1e6 + 69;
int n,x;
int B[N],ANS[N];
pair<int,int> A[N];
set< pair<int,int> > S;
int main(){
cin>>n;
for(int i=1;i<=n+1;i++){
cin>>x;
A[i] = {x,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=2;i<=n+1;i++){
S.insert( { max(A[i].ff-B[i-1],0), i } );
}
ANS[ A[1].ss ] = (*S.rbegin()).ff;
for(int i=2;i<=n+1;i++){
S.erase( { max(A[i].ff-B[i-1],0), i } );
S.insert( { max(A[i-1].ff-B[i-1],0), i-1 } );
ANS[ A[i].ss ] = (*S.rbegin()).ff;
}
for(int i=1;i<=n+1;i++){
cout<<ANS[i]<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
8 ms |
508 KB |
Output is correct |
18 |
Correct |
8 ms |
504 KB |
Output is correct |
19 |
Correct |
8 ms |
508 KB |
Output is correct |
20 |
Correct |
8 ms |
504 KB |
Output is correct |
21 |
Correct |
8 ms |
376 KB |
Output is correct |
22 |
Correct |
8 ms |
504 KB |
Output is correct |
23 |
Correct |
7 ms |
504 KB |
Output is correct |
24 |
Correct |
8 ms |
504 KB |
Output is correct |
25 |
Correct |
9 ms |
504 KB |
Output is correct |
26 |
Correct |
8 ms |
504 KB |
Output is correct |
27 |
Correct |
8 ms |
504 KB |
Output is correct |
28 |
Correct |
8 ms |
504 KB |
Output is correct |
29 |
Correct |
8 ms |
376 KB |
Output is correct |
30 |
Correct |
8 ms |
504 KB |
Output is correct |
31 |
Correct |
8 ms |
504 KB |
Output is correct |
32 |
Correct |
8 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
8 ms |
508 KB |
Output is correct |
18 |
Correct |
8 ms |
504 KB |
Output is correct |
19 |
Correct |
8 ms |
508 KB |
Output is correct |
20 |
Correct |
8 ms |
504 KB |
Output is correct |
21 |
Correct |
8 ms |
376 KB |
Output is correct |
22 |
Correct |
8 ms |
504 KB |
Output is correct |
23 |
Correct |
7 ms |
504 KB |
Output is correct |
24 |
Correct |
8 ms |
504 KB |
Output is correct |
25 |
Correct |
9 ms |
504 KB |
Output is correct |
26 |
Correct |
8 ms |
504 KB |
Output is correct |
27 |
Correct |
8 ms |
504 KB |
Output is correct |
28 |
Correct |
8 ms |
504 KB |
Output is correct |
29 |
Correct |
8 ms |
376 KB |
Output is correct |
30 |
Correct |
8 ms |
504 KB |
Output is correct |
31 |
Correct |
8 ms |
504 KB |
Output is correct |
32 |
Correct |
8 ms |
504 KB |
Output is correct |
33 |
Correct |
438 ms |
13816 KB |
Output is correct |
34 |
Correct |
465 ms |
14404 KB |
Output is correct |
35 |
Correct |
420 ms |
13920 KB |
Output is correct |
36 |
Correct |
450 ms |
14464 KB |
Output is correct |
37 |
Correct |
458 ms |
14836 KB |
Output is correct |
38 |
Correct |
431 ms |
14584 KB |
Output is correct |
39 |
Correct |
518 ms |
13688 KB |
Output is correct |
40 |
Correct |
511 ms |
13688 KB |
Output is correct |
41 |
Correct |
504 ms |
13816 KB |
Output is correct |
42 |
Correct |
505 ms |
13688 KB |
Output is correct |
43 |
Correct |
500 ms |
13844 KB |
Output is correct |
44 |
Correct |
382 ms |
13176 KB |
Output is correct |
45 |
Correct |
381 ms |
13304 KB |
Output is correct |
46 |
Correct |
389 ms |
13304 KB |
Output is correct |
47 |
Correct |
420 ms |
13436 KB |
Output is correct |
48 |
Correct |
432 ms |
13560 KB |
Output is correct |
49 |
Correct |
524 ms |
13996 KB |
Output is correct |
50 |
Correct |
524 ms |
14072 KB |
Output is correct |
51 |
Correct |
521 ms |
14072 KB |
Output is correct |
52 |
Correct |
524 ms |
14076 KB |
Output is correct |
53 |
Correct |
522 ms |
14072 KB |
Output is correct |