#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int ppl[maxn], ans[maxn];
multiset<int> st;
pair<int, int> ties[maxn];
int main(){
int n; cin >> n;
for(int i = 0; i <= n; i++) cin >> ties[i].first;
for(int i = 0; i < n; i++) cin >> ppl[i];
for(int i = 0; i <= n; i++) ties[i].second = i;
sort(ppl, ppl+n);
sort(ties, ties+n+1);
for(int i = 1; i <= n; i++) st.insert(ties[i].first-ppl[i-1]);
// ans[tie[0].second] = st.rbegin();
ans[ties[0].second] = max(0, *st.rbegin());
for(int i = 0; i < n; i++){
int id = ties[i+1].second;
// cout << i << " " << id << "\n";
st.insert(ties[i].first-ppl[i]);
st.erase(st.find(ties[i+1].first-ppl[i]));
ans[id] = max(0, *st.rbegin());
}
for(int i = 0; i <= n; i++) cout << ans[i] << " ";
cout << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
224 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
312 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 |
0 ms |
224 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
312 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 |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
3 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
232 KB |
Output is correct |
17 |
Correct |
4 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
456 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
460 KB |
Output is correct |
25 |
Correct |
3 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
352 KB |
Output is correct |
27 |
Correct |
3 ms |
452 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
328 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
224 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
312 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 |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
3 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
232 KB |
Output is correct |
17 |
Correct |
4 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
456 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
460 KB |
Output is correct |
25 |
Correct |
3 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
352 KB |
Output is correct |
27 |
Correct |
3 ms |
452 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
328 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
4 ms |
468 KB |
Output is correct |
33 |
Correct |
321 ms |
17292 KB |
Output is correct |
34 |
Correct |
285 ms |
18080 KB |
Output is correct |
35 |
Correct |
293 ms |
17616 KB |
Output is correct |
36 |
Correct |
264 ms |
17960 KB |
Output is correct |
37 |
Correct |
282 ms |
18656 KB |
Output is correct |
38 |
Correct |
283 ms |
18340 KB |
Output is correct |
39 |
Correct |
342 ms |
17400 KB |
Output is correct |
40 |
Correct |
407 ms |
17284 KB |
Output is correct |
41 |
Correct |
355 ms |
17580 KB |
Output is correct |
42 |
Correct |
351 ms |
17352 KB |
Output is correct |
43 |
Correct |
322 ms |
17188 KB |
Output is correct |
44 |
Correct |
279 ms |
16916 KB |
Output is correct |
45 |
Correct |
277 ms |
16868 KB |
Output is correct |
46 |
Correct |
264 ms |
16780 KB |
Output is correct |
47 |
Correct |
289 ms |
17192 KB |
Output is correct |
48 |
Correct |
256 ms |
17164 KB |
Output is correct |
49 |
Correct |
410 ms |
17808 KB |
Output is correct |
50 |
Correct |
333 ms |
17824 KB |
Output is correct |
51 |
Correct |
382 ms |
17784 KB |
Output is correct |
52 |
Correct |
330 ms |
17832 KB |
Output is correct |
53 |
Correct |
321 ms |
17812 KB |
Output is correct |