#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vpl;
int main() {
ios::sync_with_stdio(0);cin.tie(0);
ll n;
cin >> n;
vpl w;
vl x;
for(int i=0;i<n+1;i++) {
ll t;
cin >> t;
w.push_back({t,i});
}
sort(w.begin(),w.end());
for(int i=0;i<n;i++) {
ll t;
cin >> t;
x.push_back(t);
}
sort(x.begin(),x.end());
vl res(n+1,-1);
ll rr = 0;
for(int i=0;i<n;i++) {
rr = max(rr,w[i].first-x[i]);
res[i+1] = max(res[i+1],rr);
}
rr = 0;
for(int i=n-1;i>=0;i--) {
rr = max(rr,w[i+1].first-x[i]);
res[i] = max(res[i],rr);
}
vl ans(n+1);
for(int i=0;i<=n;i++) {
ans[w[i].second] = res[i];
}
for(int i=0;i<=n;i++) {
if(i > 0) {cout << " ";}
cout << ans[i];
}
cout << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
544 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
6 ms |
640 KB |
Output is correct |
29 |
Correct |
5 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
544 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
6 ms |
640 KB |
Output is correct |
29 |
Correct |
5 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
132 ms |
9952 KB |
Output is correct |
34 |
Correct |
115 ms |
10212 KB |
Output is correct |
35 |
Correct |
112 ms |
10008 KB |
Output is correct |
36 |
Correct |
116 ms |
10340 KB |
Output is correct |
37 |
Correct |
122 ms |
10592 KB |
Output is correct |
38 |
Correct |
118 ms |
10720 KB |
Output is correct |
39 |
Correct |
115 ms |
9696 KB |
Output is correct |
40 |
Correct |
114 ms |
9564 KB |
Output is correct |
41 |
Correct |
110 ms |
9700 KB |
Output is correct |
42 |
Correct |
127 ms |
9696 KB |
Output is correct |
43 |
Correct |
112 ms |
9692 KB |
Output is correct |
44 |
Correct |
112 ms |
9312 KB |
Output is correct |
45 |
Correct |
114 ms |
9440 KB |
Output is correct |
46 |
Correct |
108 ms |
9440 KB |
Output is correct |
47 |
Correct |
106 ms |
9184 KB |
Output is correct |
48 |
Correct |
107 ms |
9184 KB |
Output is correct |
49 |
Correct |
114 ms |
9952 KB |
Output is correct |
50 |
Correct |
117 ms |
9824 KB |
Output is correct |
51 |
Correct |
113 ms |
9824 KB |
Output is correct |
52 |
Correct |
117 ms |
9952 KB |
Output is correct |
53 |
Correct |
114 ms |
9828 KB |
Output is correct |