#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define sc second
#define pb push_back
#define in insert
int32_t main () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll o = 1; //cin>>o;
while (o--) {
ll n; cin>>n;
vector<ll> b(n + 1);
vector<pair<ll,ll>> a(n + 2);
a[0].ff = 0; b[0] = 0;
for (int i = 1; i <= n + 1; i++){
cin>>a[i].ff;
a[i].sc = i;
}
for(int i = 1; i <= n; i++)
cin>>b[i];
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector<ll> p(n + 1),s(n + 2);
p[0] = 0; s[n + 1] = 0;
for (int i = 1; i <= n; i++) {
p[i] = max(p[i - 1] , (a[i].ff - b[i]));
//cout<<p[i]<<" ";
}
for (int i = n; i > 0; i--) {
s[i] = max(s[i + 1] , (a[i + 1].ff - b[i]));
//cout<<s[i]<<" ";
}
vector<ll> ans(n + 2);
for (int i = 1; i <= n + 1; i++) {
ans[a[i].sc] = max(p[i - 1],s[i]);
}
for (int i = 1; i <= n + 1; i++) {
cout<<ans[i]<<" ";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
256 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 |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
0 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 |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
256 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 |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
0 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 |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
111 ms |
10680 KB |
Output is correct |
34 |
Correct |
113 ms |
11120 KB |
Output is correct |
35 |
Correct |
100 ms |
10820 KB |
Output is correct |
36 |
Correct |
98 ms |
11248 KB |
Output is correct |
37 |
Correct |
108 ms |
11656 KB |
Output is correct |
38 |
Correct |
124 ms |
11468 KB |
Output is correct |
39 |
Correct |
95 ms |
10500 KB |
Output is correct |
40 |
Correct |
90 ms |
10496 KB |
Output is correct |
41 |
Correct |
104 ms |
10668 KB |
Output is correct |
42 |
Correct |
97 ms |
10540 KB |
Output is correct |
43 |
Correct |
100 ms |
10500 KB |
Output is correct |
44 |
Correct |
90 ms |
10060 KB |
Output is correct |
45 |
Correct |
94 ms |
10204 KB |
Output is correct |
46 |
Correct |
99 ms |
10060 KB |
Output is correct |
47 |
Correct |
93 ms |
10144 KB |
Output is correct |
48 |
Correct |
86 ms |
10260 KB |
Output is correct |
49 |
Correct |
100 ms |
10896 KB |
Output is correct |
50 |
Correct |
120 ms |
10828 KB |
Output is correct |
51 |
Correct |
93 ms |
10828 KB |
Output is correct |
52 |
Correct |
93 ms |
10768 KB |
Output is correct |
53 |
Correct |
100 ms |
10768 KB |
Output is correct |