#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,b[200005];
pair<int,int> a[200005];
int ans[200005];
int d1[200005],d2[200005];
int maxpref[200005],maxsuf[200005];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
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(b + 1,b + n + 1);
sort(a + 1,a + n + 2);
for (int i = 1; i <= n; i++)
d1[i] = abs(a[i].first - b[i]);
for (int i = 1; i <= n; i++)
d2[i] = abs(a[i + 1].first - b[i]);
maxpref[0] = 0;
maxsuf[n + 1] = 0;
for (int i = 1; i <= n + 1; i++)
{
int mx = 0;
for (int j = 1; j < i; j++)
mx = max(mx,a[j].first - b[j]);
for (int j = i; j <= n; j++)
mx = max(mx,a[j + 1].first - b[j]);
ans[a[i].second] = mx;
}
for (int i = 1; i <= n + 1; i++)
cout << ans[i] << ' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10840 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10724 KB |
Output is correct |
4 |
Correct |
1 ms |
10584 KB |
Output is correct |
5 |
Correct |
1 ms |
10716 KB |
Output is correct |
6 |
Correct |
1 ms |
10588 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
2 ms |
10840 KB |
Output is correct |
9 |
Correct |
2 ms |
10584 KB |
Output is correct |
10 |
Correct |
1 ms |
10588 KB |
Output is correct |
11 |
Correct |
1 ms |
10716 KB |
Output is correct |
12 |
Correct |
1 ms |
10588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10840 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10724 KB |
Output is correct |
4 |
Correct |
1 ms |
10584 KB |
Output is correct |
5 |
Correct |
1 ms |
10716 KB |
Output is correct |
6 |
Correct |
1 ms |
10588 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
2 ms |
10840 KB |
Output is correct |
9 |
Correct |
2 ms |
10584 KB |
Output is correct |
10 |
Correct |
1 ms |
10588 KB |
Output is correct |
11 |
Correct |
1 ms |
10716 KB |
Output is correct |
12 |
Correct |
1 ms |
10588 KB |
Output is correct |
13 |
Correct |
2 ms |
10584 KB |
Output is correct |
14 |
Correct |
2 ms |
10632 KB |
Output is correct |
15 |
Correct |
4 ms |
10588 KB |
Output is correct |
16 |
Correct |
1 ms |
10588 KB |
Output is correct |
17 |
Correct |
5 ms |
10588 KB |
Output is correct |
18 |
Correct |
4 ms |
10764 KB |
Output is correct |
19 |
Correct |
4 ms |
10588 KB |
Output is correct |
20 |
Correct |
5 ms |
10588 KB |
Output is correct |
21 |
Correct |
5 ms |
10588 KB |
Output is correct |
22 |
Correct |
5 ms |
10584 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
10760 KB |
Output is correct |
25 |
Correct |
6 ms |
10584 KB |
Output is correct |
26 |
Correct |
5 ms |
10840 KB |
Output is correct |
27 |
Correct |
5 ms |
10768 KB |
Output is correct |
28 |
Correct |
5 ms |
10588 KB |
Output is correct |
29 |
Correct |
4 ms |
10840 KB |
Output is correct |
30 |
Correct |
5 ms |
10588 KB |
Output is correct |
31 |
Correct |
5 ms |
10760 KB |
Output is correct |
32 |
Correct |
6 ms |
10840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10840 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10724 KB |
Output is correct |
4 |
Correct |
1 ms |
10584 KB |
Output is correct |
5 |
Correct |
1 ms |
10716 KB |
Output is correct |
6 |
Correct |
1 ms |
10588 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
2 ms |
10840 KB |
Output is correct |
9 |
Correct |
2 ms |
10584 KB |
Output is correct |
10 |
Correct |
1 ms |
10588 KB |
Output is correct |
11 |
Correct |
1 ms |
10716 KB |
Output is correct |
12 |
Correct |
1 ms |
10588 KB |
Output is correct |
13 |
Correct |
2 ms |
10584 KB |
Output is correct |
14 |
Correct |
2 ms |
10632 KB |
Output is correct |
15 |
Correct |
4 ms |
10588 KB |
Output is correct |
16 |
Correct |
1 ms |
10588 KB |
Output is correct |
17 |
Correct |
5 ms |
10588 KB |
Output is correct |
18 |
Correct |
4 ms |
10764 KB |
Output is correct |
19 |
Correct |
4 ms |
10588 KB |
Output is correct |
20 |
Correct |
5 ms |
10588 KB |
Output is correct |
21 |
Correct |
5 ms |
10588 KB |
Output is correct |
22 |
Correct |
5 ms |
10584 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
10760 KB |
Output is correct |
25 |
Correct |
6 ms |
10584 KB |
Output is correct |
26 |
Correct |
5 ms |
10840 KB |
Output is correct |
27 |
Correct |
5 ms |
10768 KB |
Output is correct |
28 |
Correct |
5 ms |
10588 KB |
Output is correct |
29 |
Correct |
4 ms |
10840 KB |
Output is correct |
30 |
Correct |
5 ms |
10588 KB |
Output is correct |
31 |
Correct |
5 ms |
10760 KB |
Output is correct |
32 |
Correct |
6 ms |
10840 KB |
Output is correct |
33 |
Execution timed out |
1054 ms |
16304 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |