#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> t1(n + 1);
vector<int> t2(n);
vector<int> p;
vector<int> t;
for(int i = 0; i < n + 1; i++)
{
cin >> t1[i];
}
vector<int> z = t1;
for (int i = 0; i < n; i++)
{
cin >> t2[i];
}
sort(t1.begin(), t1.end());
sort(t2.begin(), t2.end());
int m = 0;
for (int i = 0; i < n; i++)
{
if (t1[i] - t2[i] > m)
{
m = t1[i] - t2[i];
}
p.push_back(m);
}
m = 0;
for (int i = n; i > 0; i--)
{
if (t1[i] - t2[i - 1] > m)
{
m = t1[i] - t2[i - 1];
}
t.push_back(m);
}
reverse(t.begin(), t.end());
map<int, int> wyn;
wyn[t1[0]] = t[0];
for (int i = 0; i < n - 1; i++)
{
wyn[t1[i + 1]] = max(p[i], t[i + 1]);
}
wyn[t1[n]] = p[p.size() - 1];
for (int i : z) {
cout << wyn[i] << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
3 ms |
336 KB |
Output is correct |
18 |
Correct |
2 ms |
336 KB |
Output is correct |
19 |
Correct |
2 ms |
336 KB |
Output is correct |
20 |
Correct |
2 ms |
336 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
504 KB |
Output is correct |
23 |
Correct |
2 ms |
544 KB |
Output is correct |
24 |
Correct |
2 ms |
400 KB |
Output is correct |
25 |
Correct |
2 ms |
336 KB |
Output is correct |
26 |
Correct |
2 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
504 KB |
Output is correct |
30 |
Correct |
2 ms |
336 KB |
Output is correct |
31 |
Correct |
2 ms |
336 KB |
Output is correct |
32 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
3 ms |
336 KB |
Output is correct |
18 |
Correct |
2 ms |
336 KB |
Output is correct |
19 |
Correct |
2 ms |
336 KB |
Output is correct |
20 |
Correct |
2 ms |
336 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
504 KB |
Output is correct |
23 |
Correct |
2 ms |
544 KB |
Output is correct |
24 |
Correct |
2 ms |
400 KB |
Output is correct |
25 |
Correct |
2 ms |
336 KB |
Output is correct |
26 |
Correct |
2 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
504 KB |
Output is correct |
30 |
Correct |
2 ms |
336 KB |
Output is correct |
31 |
Correct |
2 ms |
336 KB |
Output is correct |
32 |
Correct |
2 ms |
336 KB |
Output is correct |
33 |
Correct |
224 ms |
14400 KB |
Output is correct |
34 |
Correct |
253 ms |
15164 KB |
Output is correct |
35 |
Correct |
233 ms |
14652 KB |
Output is correct |
36 |
Correct |
234 ms |
15164 KB |
Output is correct |
37 |
Correct |
247 ms |
15552 KB |
Output is correct |
38 |
Correct |
235 ms |
15272 KB |
Output is correct |
39 |
Correct |
239 ms |
14396 KB |
Output is correct |
40 |
Correct |
230 ms |
14400 KB |
Output is correct |
41 |
Correct |
242 ms |
14504 KB |
Output is correct |
42 |
Correct |
222 ms |
14400 KB |
Output is correct |
43 |
Correct |
214 ms |
14316 KB |
Output is correct |
44 |
Correct |
203 ms |
13884 KB |
Output is correct |
45 |
Correct |
214 ms |
13964 KB |
Output is correct |
46 |
Correct |
217 ms |
13884 KB |
Output is correct |
47 |
Correct |
168 ms |
6716 KB |
Output is correct |
48 |
Correct |
170 ms |
6596 KB |
Output is correct |
49 |
Correct |
261 ms |
14912 KB |
Output is correct |
50 |
Correct |
258 ms |
14908 KB |
Output is correct |
51 |
Correct |
245 ms |
14784 KB |
Output is correct |
52 |
Correct |
238 ms |
14784 KB |
Output is correct |
53 |
Correct |
222 ms |
14684 KB |
Output is correct |