#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;
ll a[N], A[N], b[N];
ll p[N], s[N];
map<ll, ll> mp;
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
for(int i = 0; i <= n; i++) cin >> a[i];
for(int i = 0; i < n; i++) cin >> b[i];
memcpy(A, a, sizeof a);
sort(a, a + n + 1);
sort(b, b + n);
for(int i = 1; i <= n; i++) p[i] = max(p[i - 1], a[i - 1] - b[i - 1]);
for(int i = n; i > 0; i--) s[i] = max(s[i + 1], a[i] - b[i - 1]);
for(int i = 0; i <= n; i++) mp[a[i]] = max(p[i], s[i + 1]);
for(int i = 0; i <= n; i++) cout << mp[A[i]] << ' ';
cout << '\n';
return 0;
}
/*
5
4 7 9 10 11 12
3 5 7 9 11
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1912 KB |
Output is correct |
2 |
Correct |
6 ms |
1912 KB |
Output is correct |
3 |
Correct |
7 ms |
1912 KB |
Output is correct |
4 |
Correct |
6 ms |
1912 KB |
Output is correct |
5 |
Correct |
7 ms |
1912 KB |
Output is correct |
6 |
Correct |
7 ms |
1912 KB |
Output is correct |
7 |
Correct |
7 ms |
1912 KB |
Output is correct |
8 |
Correct |
7 ms |
1912 KB |
Output is correct |
9 |
Correct |
7 ms |
1912 KB |
Output is correct |
10 |
Correct |
8 ms |
1912 KB |
Output is correct |
11 |
Correct |
8 ms |
1912 KB |
Output is correct |
12 |
Correct |
7 ms |
1912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1912 KB |
Output is correct |
2 |
Correct |
6 ms |
1912 KB |
Output is correct |
3 |
Correct |
7 ms |
1912 KB |
Output is correct |
4 |
Correct |
6 ms |
1912 KB |
Output is correct |
5 |
Correct |
7 ms |
1912 KB |
Output is correct |
6 |
Correct |
7 ms |
1912 KB |
Output is correct |
7 |
Correct |
7 ms |
1912 KB |
Output is correct |
8 |
Correct |
7 ms |
1912 KB |
Output is correct |
9 |
Correct |
7 ms |
1912 KB |
Output is correct |
10 |
Correct |
8 ms |
1912 KB |
Output is correct |
11 |
Correct |
8 ms |
1912 KB |
Output is correct |
12 |
Correct |
7 ms |
1912 KB |
Output is correct |
13 |
Correct |
7 ms |
1912 KB |
Output is correct |
14 |
Correct |
8 ms |
2096 KB |
Output is correct |
15 |
Correct |
8 ms |
2040 KB |
Output is correct |
16 |
Correct |
7 ms |
1912 KB |
Output is correct |
17 |
Correct |
9 ms |
2036 KB |
Output is correct |
18 |
Correct |
8 ms |
2040 KB |
Output is correct |
19 |
Correct |
8 ms |
2040 KB |
Output is correct |
20 |
Correct |
8 ms |
2040 KB |
Output is correct |
21 |
Correct |
8 ms |
2040 KB |
Output is correct |
22 |
Correct |
8 ms |
2168 KB |
Output is correct |
23 |
Correct |
9 ms |
2040 KB |
Output is correct |
24 |
Correct |
9 ms |
2168 KB |
Output is correct |
25 |
Correct |
9 ms |
2168 KB |
Output is correct |
26 |
Correct |
8 ms |
2040 KB |
Output is correct |
27 |
Correct |
8 ms |
2040 KB |
Output is correct |
28 |
Correct |
8 ms |
2168 KB |
Output is correct |
29 |
Correct |
8 ms |
2168 KB |
Output is correct |
30 |
Correct |
8 ms |
2168 KB |
Output is correct |
31 |
Correct |
9 ms |
2168 KB |
Output is correct |
32 |
Correct |
8 ms |
2168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1912 KB |
Output is correct |
2 |
Correct |
6 ms |
1912 KB |
Output is correct |
3 |
Correct |
7 ms |
1912 KB |
Output is correct |
4 |
Correct |
6 ms |
1912 KB |
Output is correct |
5 |
Correct |
7 ms |
1912 KB |
Output is correct |
6 |
Correct |
7 ms |
1912 KB |
Output is correct |
7 |
Correct |
7 ms |
1912 KB |
Output is correct |
8 |
Correct |
7 ms |
1912 KB |
Output is correct |
9 |
Correct |
7 ms |
1912 KB |
Output is correct |
10 |
Correct |
8 ms |
1912 KB |
Output is correct |
11 |
Correct |
8 ms |
1912 KB |
Output is correct |
12 |
Correct |
7 ms |
1912 KB |
Output is correct |
13 |
Correct |
7 ms |
1912 KB |
Output is correct |
14 |
Correct |
8 ms |
2096 KB |
Output is correct |
15 |
Correct |
8 ms |
2040 KB |
Output is correct |
16 |
Correct |
7 ms |
1912 KB |
Output is correct |
17 |
Correct |
9 ms |
2036 KB |
Output is correct |
18 |
Correct |
8 ms |
2040 KB |
Output is correct |
19 |
Correct |
8 ms |
2040 KB |
Output is correct |
20 |
Correct |
8 ms |
2040 KB |
Output is correct |
21 |
Correct |
8 ms |
2040 KB |
Output is correct |
22 |
Correct |
8 ms |
2168 KB |
Output is correct |
23 |
Correct |
9 ms |
2040 KB |
Output is correct |
24 |
Correct |
9 ms |
2168 KB |
Output is correct |
25 |
Correct |
9 ms |
2168 KB |
Output is correct |
26 |
Correct |
8 ms |
2040 KB |
Output is correct |
27 |
Correct |
8 ms |
2040 KB |
Output is correct |
28 |
Correct |
8 ms |
2168 KB |
Output is correct |
29 |
Correct |
8 ms |
2168 KB |
Output is correct |
30 |
Correct |
8 ms |
2168 KB |
Output is correct |
31 |
Correct |
9 ms |
2168 KB |
Output is correct |
32 |
Correct |
8 ms |
2168 KB |
Output is correct |
33 |
Correct |
388 ms |
21336 KB |
Output is correct |
34 |
Correct |
380 ms |
22240 KB |
Output is correct |
35 |
Correct |
366 ms |
21496 KB |
Output is correct |
36 |
Correct |
344 ms |
22020 KB |
Output is correct |
37 |
Correct |
369 ms |
22624 KB |
Output is correct |
38 |
Correct |
374 ms |
22456 KB |
Output is correct |
39 |
Correct |
394 ms |
21312 KB |
Output is correct |
40 |
Correct |
376 ms |
21300 KB |
Output is correct |
41 |
Correct |
332 ms |
21496 KB |
Output is correct |
42 |
Correct |
361 ms |
21464 KB |
Output is correct |
43 |
Correct |
336 ms |
21244 KB |
Output is correct |
44 |
Correct |
346 ms |
20856 KB |
Output is correct |
45 |
Correct |
354 ms |
20892 KB |
Output is correct |
46 |
Correct |
351 ms |
20696 KB |
Output is correct |
47 |
Correct |
165 ms |
11256 KB |
Output is correct |
48 |
Correct |
160 ms |
11256 KB |
Output is correct |
49 |
Correct |
376 ms |
21988 KB |
Output is correct |
50 |
Correct |
371 ms |
21880 KB |
Output is correct |
51 |
Correct |
353 ms |
21880 KB |
Output is correct |
52 |
Correct |
372 ms |
21880 KB |
Output is correct |
53 |
Correct |
355 ms |
21880 KB |
Output is correct |