#include<bits/stdc++.h>
using namespace std;
pair<int, int> a[200002];
int b[200002], diff1[200005], diff2[200005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
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++){
diff1[i] = max(a[i].first - b[i], 0);
diff2[i] = max(a[i+1].first - b[i], 0);
diff1[i] = max(diff1[i], diff1[i-1]);
}
for(int i = n-1; i >= 1; i--) diff2[i] = max(diff2[i], diff2[i+1]);
vector<pair<int, int>> ans;
for(int i = 1; i <= n+1; i++){
ans.push_back(make_pair(a[i].second, max(diff1[i-1], diff2[i])));
}
sort(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i++) cout<<ans[i].second<<" ";
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i = 0; i < ans.size(); i++) cout<<ans[i].second<<" ";
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 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 |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
0 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 |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 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 |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
0 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 |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
81 ms |
7088 KB |
Output is correct |
34 |
Correct |
86 ms |
7448 KB |
Output is correct |
35 |
Correct |
81 ms |
7212 KB |
Output is correct |
36 |
Correct |
84 ms |
7692 KB |
Output is correct |
37 |
Correct |
85 ms |
7876 KB |
Output is correct |
38 |
Correct |
84 ms |
7752 KB |
Output is correct |
39 |
Correct |
82 ms |
6944 KB |
Output is correct |
40 |
Correct |
82 ms |
6796 KB |
Output is correct |
41 |
Correct |
83 ms |
6956 KB |
Output is correct |
42 |
Correct |
82 ms |
6932 KB |
Output is correct |
43 |
Correct |
88 ms |
6932 KB |
Output is correct |
44 |
Correct |
80 ms |
6480 KB |
Output is correct |
45 |
Correct |
81 ms |
6524 KB |
Output is correct |
46 |
Correct |
82 ms |
6596 KB |
Output is correct |
47 |
Correct |
75 ms |
6488 KB |
Output is correct |
48 |
Correct |
77 ms |
6444 KB |
Output is correct |
49 |
Correct |
83 ms |
7076 KB |
Output is correct |
50 |
Correct |
84 ms |
7020 KB |
Output is correct |
51 |
Correct |
84 ms |
7080 KB |
Output is correct |
52 |
Correct |
84 ms |
7084 KB |
Output is correct |
53 |
Correct |
85 ms |
7076 KB |
Output is correct |