#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
pair<int,int>a[n+2],res[n+2];
int b[n+1];
int pref[n+1],suf[n+2];
suf[0]=-1;
suf[n+1]=pref[0]=0;
for(int i=1;i<=n+1;i++){
cin>>a[i].first;
a[i].second=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++)pref[i]=max(pref[i-1],a[i].first-b[i]);
for(int i=n;i>=1;i--)suf[i]=max(suf[i+1],a[i+1].first-b[i]);
for(int i=1;i<=n+1;i++)res[i]={a[i].second,max(pref[i-1],suf[i])};
sort(res+1,res+n+2);
for(int i=1;i<=n+1;i++)cout<<res[i].second<<" ";
cout<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
456 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
456 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
588 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
584 KB |
Output is correct |
29 |
Correct |
1 ms |
472 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
388 KB |
Output is correct |
32 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
456 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
588 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
584 KB |
Output is correct |
29 |
Correct |
1 ms |
472 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
388 KB |
Output is correct |
32 |
Correct |
1 ms |
600 KB |
Output is correct |
33 |
Correct |
79 ms |
15952 KB |
Output is correct |
34 |
Correct |
83 ms |
16720 KB |
Output is correct |
35 |
Correct |
81 ms |
16048 KB |
Output is correct |
36 |
Correct |
82 ms |
16464 KB |
Output is correct |
37 |
Correct |
82 ms |
16976 KB |
Output is correct |
38 |
Correct |
87 ms |
16976 KB |
Output is correct |
39 |
Correct |
79 ms |
15952 KB |
Output is correct |
40 |
Correct |
80 ms |
15696 KB |
Output is correct |
41 |
Correct |
83 ms |
15880 KB |
Output is correct |
42 |
Correct |
80 ms |
15924 KB |
Output is correct |
43 |
Correct |
80 ms |
15700 KB |
Output is correct |
44 |
Correct |
78 ms |
15444 KB |
Output is correct |
45 |
Correct |
79 ms |
15436 KB |
Output is correct |
46 |
Correct |
93 ms |
15312 KB |
Output is correct |
47 |
Correct |
69 ms |
15744 KB |
Output is correct |
48 |
Correct |
71 ms |
15812 KB |
Output is correct |
49 |
Correct |
84 ms |
16208 KB |
Output is correct |
50 |
Correct |
87 ms |
16208 KB |
Output is correct |
51 |
Correct |
95 ms |
16248 KB |
Output is correct |
52 |
Correct |
95 ms |
16272 KB |
Output is correct |
53 |
Correct |
83 ms |
16252 KB |
Output is correct |