#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 2e5 + 5;
ll n, x, b[NMAX], ans[NMAX];
vector<pair<ll, ll>> v;
multiset<ll> s;
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 0; i <= n; i++) {
cin >> x;
v.emplace_back(x, i);
}
for(int i = 0; i < n; i++) cin >> b[i];
sort(all(v));
sort(b, b + n);
for(int i = 0; i < n; i++) s.emplace(v[i + 1].first - b[i]);
ans[v[0].second] = max(*s.rbegin(), 0LL);
for(int i = 1; i <= n; i++){
auto&[x, ix] = v[i];
s.erase(s.find(x - b[i - 1]));
s.emplace(v[i - 1].first - b[i - 1]);
ans[ix] = max(*s.rbegin(), 0LL);
}
for(int i = 0; i <= n; i++) cout << ans[i] << ' ';
return 0;
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:26:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
26 | auto&[x, ix] = v[i];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
380 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
328 KB |
Output is correct |
17 |
Correct |
3 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
2 ms |
396 KB |
Output is correct |
23 |
Correct |
3 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
524 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
380 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
328 KB |
Output is correct |
17 |
Correct |
3 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
2 ms |
396 KB |
Output is correct |
23 |
Correct |
3 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
524 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
144 ms |
20400 KB |
Output is correct |
34 |
Correct |
176 ms |
21280 KB |
Output is correct |
35 |
Correct |
147 ms |
20504 KB |
Output is correct |
36 |
Correct |
159 ms |
21116 KB |
Output is correct |
37 |
Correct |
153 ms |
21784 KB |
Output is correct |
38 |
Correct |
171 ms |
21464 KB |
Output is correct |
39 |
Correct |
200 ms |
20340 KB |
Output is correct |
40 |
Correct |
195 ms |
20268 KB |
Output is correct |
41 |
Correct |
189 ms |
20488 KB |
Output is correct |
42 |
Correct |
210 ms |
20524 KB |
Output is correct |
43 |
Correct |
189 ms |
20268 KB |
Output is correct |
44 |
Correct |
164 ms |
19748 KB |
Output is correct |
45 |
Correct |
145 ms |
19936 KB |
Output is correct |
46 |
Correct |
149 ms |
19776 KB |
Output is correct |
47 |
Correct |
144 ms |
20392 KB |
Output is correct |
48 |
Correct |
128 ms |
20364 KB |
Output is correct |
49 |
Correct |
208 ms |
20988 KB |
Output is correct |
50 |
Correct |
194 ms |
21116 KB |
Output is correct |
51 |
Correct |
193 ms |
20996 KB |
Output is correct |
52 |
Correct |
205 ms |
20992 KB |
Output is correct |
53 |
Correct |
195 ms |
20956 KB |
Output is correct |