#include <iostream>
#include <fstream>
#include <climits>
#include <cstring>
#include <algorithm>
using namespace std;
const int nmax=2e5+5;
int n, v[nmax], b[nmax], rez[nmax];
struct tie
{
int poz, val;
} v1[nmax];
bool compare (tie a, tie b)
{
return a.val<b.val;
}
int main()
{
cin >> n;
for (int i=1;i<=n+1;i++)
{
cin >> v[i];
v1[i]={i, v[i]};
}
for (int i=1;i<=n;i++)
{
cin >> b[i];
}
sort (b+1, b+n+1);
sort (v1+1, v1+n+2, compare);
int mx=0;
for (int i=1;i<=n;i++)
{
mx=max (mx, max (0, v1[i].val-b[i]));
}
rez[v1[n+1].poz]=mx;
for (int i=n;i>=1;i--)
{
mx=max (mx, max (0, v1[i+1].val-b[i]));
rez[v1[i].poz]=mx;
}
for (int i=1;i<=n+1;i++)
{
cout << rez[i] << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
2 ms |
2396 KB |
Output is correct |
18 |
Correct |
2 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
2 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
26 |
Correct |
2 ms |
2396 KB |
Output is correct |
27 |
Correct |
2 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2512 KB |
Output is correct |
29 |
Correct |
2 ms |
2396 KB |
Output is correct |
30 |
Correct |
2 ms |
2396 KB |
Output is correct |
31 |
Correct |
1 ms |
2396 KB |
Output is correct |
32 |
Correct |
2 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
2 ms |
2396 KB |
Output is correct |
18 |
Correct |
2 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
2 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
26 |
Correct |
2 ms |
2396 KB |
Output is correct |
27 |
Correct |
2 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2512 KB |
Output is correct |
29 |
Correct |
2 ms |
2396 KB |
Output is correct |
30 |
Correct |
2 ms |
2396 KB |
Output is correct |
31 |
Correct |
1 ms |
2396 KB |
Output is correct |
32 |
Correct |
2 ms |
2396 KB |
Output is correct |
33 |
Correct |
130 ms |
9304 KB |
Output is correct |
34 |
Correct |
146 ms |
9552 KB |
Output is correct |
35 |
Correct |
132 ms |
9300 KB |
Output is correct |
36 |
Correct |
131 ms |
9720 KB |
Output is correct |
37 |
Correct |
137 ms |
10112 KB |
Output is correct |
38 |
Correct |
133 ms |
9972 KB |
Output is correct |
39 |
Correct |
137 ms |
8956 KB |
Output is correct |
40 |
Correct |
141 ms |
9044 KB |
Output is correct |
41 |
Correct |
196 ms |
9040 KB |
Output is correct |
42 |
Correct |
137 ms |
9040 KB |
Output is correct |
43 |
Correct |
142 ms |
8964 KB |
Output is correct |
44 |
Correct |
146 ms |
8608 KB |
Output is correct |
45 |
Correct |
132 ms |
8656 KB |
Output is correct |
46 |
Correct |
132 ms |
8784 KB |
Output is correct |
47 |
Correct |
143 ms |
8640 KB |
Output is correct |
48 |
Correct |
132 ms |
8788 KB |
Output is correct |
49 |
Correct |
137 ms |
9300 KB |
Output is correct |
50 |
Correct |
139 ms |
9296 KB |
Output is correct |
51 |
Correct |
143 ms |
9144 KB |
Output is correct |
52 |
Correct |
138 ms |
9296 KB |
Output is correct |
53 |
Correct |
135 ms |
9300 KB |
Output is correct |