#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 2e5 + 69;
ll n;
pair<ll,ll> a[maxn];
ll b[maxn];
multiset<ll> s;
int main(){
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+1;i++){
cout << a[i].first << " ";
}
cout << endl;
for(int i = 1;i<=n;i++){
cout << b[i] << " ";
}
cout << endl;*/
for(int i = 1;i<=n;i++){
s.insert(max(0ll,a[i+1].first - b[i]));
}
vector<ll> ans(n+1);
ans[a[1].second-1] = *s.rbegin();
for(int i = 1;i<=n;i++){
s.erase(s.find(max(a[i+1].first - b[i],0ll)));
s.insert(max(0ll,a[i].first - b[i]));
ans[a[i+1].second-1] = *s.rbegin();
}
for(auto i:ans) cout << i << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
3 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
3 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
468 KB |
Output is correct |
33 |
Correct |
219 ms |
16660 KB |
Output is correct |
34 |
Correct |
242 ms |
17428 KB |
Output is correct |
35 |
Correct |
218 ms |
16816 KB |
Output is correct |
36 |
Correct |
241 ms |
17320 KB |
Output is correct |
37 |
Correct |
238 ms |
18000 KB |
Output is correct |
38 |
Correct |
224 ms |
17672 KB |
Output is correct |
39 |
Correct |
266 ms |
16592 KB |
Output is correct |
40 |
Correct |
265 ms |
16480 KB |
Output is correct |
41 |
Correct |
270 ms |
16704 KB |
Output is correct |
42 |
Correct |
286 ms |
16640 KB |
Output is correct |
43 |
Correct |
263 ms |
16504 KB |
Output is correct |
44 |
Correct |
204 ms |
16072 KB |
Output is correct |
45 |
Correct |
200 ms |
16184 KB |
Output is correct |
46 |
Correct |
202 ms |
16084 KB |
Output is correct |
47 |
Correct |
214 ms |
16440 KB |
Output is correct |
48 |
Correct |
259 ms |
16504 KB |
Output is correct |
49 |
Correct |
273 ms |
17100 KB |
Output is correct |
50 |
Correct |
275 ms |
17064 KB |
Output is correct |
51 |
Correct |
278 ms |
17092 KB |
Output is correct |
52 |
Correct |
280 ms |
17100 KB |
Output is correct |
53 |
Correct |
339 ms |
17024 KB |
Output is correct |