#include <bits/stdc++.h>
using namespace std;
#define di pair<int, int>
int nbTypes;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> nbTypes;
vector<di> a(nbTypes + 1);
for (int iT = 0; iT <= nbTypes; iT ++) {
int x;
cin >> x;
a[iT] = { x, iT };
}
vector<int> b(nbTypes);
for (int jT = 0; jT < nbTypes; jT ++)
cin >> b[jT];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
vector<int> c(nbTypes + 1);
vector<int> d(nbTypes + 1);
for (int iT = 0; iT < nbTypes; iT ++) {
c[iT] = a[iT].first - b[iT];
d[iT + 1] = a[iT + 1].first - b[iT];
}
for (int iT = 1; iT <= nbTypes; iT ++)
c[iT] = max(c[iT], c[iT - 1]);
for (int jT = nbTypes - 1; jT >= 0; jT --)
d[jT] = max(d[jT + 1], d[jT]);
vector<int> res (nbTypes + 1);
for (int i = 0; i <= nbTypes; i ++) {
int mu = i == 0 ? 0 : c[i - 1];
int nu = i == nbTypes ? 0 : d[i + 1];
res[a[i].second] = max(mu, nu);
}
for (int u : res)
cout << u << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
320 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 |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 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 |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
320 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 |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
360 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
332 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 |
368 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
320 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 |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
360 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
332 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 |
368 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
372 KB |
Output is correct |
33 |
Correct |
83 ms |
9980 KB |
Output is correct |
34 |
Correct |
87 ms |
10308 KB |
Output is correct |
35 |
Correct |
90 ms |
10004 KB |
Output is correct |
36 |
Correct |
86 ms |
10444 KB |
Output is correct |
37 |
Correct |
113 ms |
10820 KB |
Output is correct |
38 |
Correct |
91 ms |
10668 KB |
Output is correct |
39 |
Correct |
86 ms |
9788 KB |
Output is correct |
40 |
Correct |
88 ms |
9804 KB |
Output is correct |
41 |
Correct |
82 ms |
9776 KB |
Output is correct |
42 |
Correct |
88 ms |
9768 KB |
Output is correct |
43 |
Correct |
88 ms |
9740 KB |
Output is correct |
44 |
Correct |
80 ms |
9360 KB |
Output is correct |
45 |
Correct |
85 ms |
9344 KB |
Output is correct |
46 |
Correct |
93 ms |
9288 KB |
Output is correct |
47 |
Correct |
92 ms |
9388 KB |
Output is correct |
48 |
Correct |
85 ms |
9416 KB |
Output is correct |
49 |
Correct |
86 ms |
10036 KB |
Output is correct |
50 |
Correct |
107 ms |
9968 KB |
Output is correct |
51 |
Correct |
85 ms |
9984 KB |
Output is correct |
52 |
Correct |
85 ms |
9948 KB |
Output is correct |
53 |
Correct |
91 ms |
9988 KB |
Output is correct |