#include <bits/stdc++.h>
#define B begin()
#define E end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define sts stable_sort
using namespace std;
const int MAXN = 1e6 + 4;
const int MOD = 1e9 + 7;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<ll> v(n + 1);
vector<ll> asd(n + 1);
vector<ll> b(n);
for(int i = 0; i <= n; i++){
cin >> v[i];
asd[i] = v[i];
}
sts(v.B, v.E);
for(int i = 0; i < n; i++){
cin >> b[i];
}
sts(b.B, b.E);
map<ll, ll> m;
map<ll, ll> mmax;
ll maxdesp = 0;
for(int i = n; i > 0; i--){
maxdesp = max(maxdesp, (v[i] - b[i - 1]));
// cout << maxdesp << " " << i << "\n";
mmax[i] = maxdesp;
}
ll maxant = 0;
for(int i = 0; i <= n; i++){
if(i < n){
maxant = max(maxant, (v[i] - b[i]));
}
// cout << maxant << "\n";
m[v[i]] = max(maxant, mmax[i + 1]);
}
for(int i = 0; i <= n; i++){
cout << m[asd[i]] << " ";
}cout << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 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 |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
360 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
520 KB |
Output is correct |
20 |
Correct |
2 ms |
596 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
2 ms |
584 KB |
Output is correct |
23 |
Correct |
2 ms |
592 KB |
Output is correct |
24 |
Correct |
2 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
536 KB |
Output is correct |
26 |
Correct |
2 ms |
588 KB |
Output is correct |
27 |
Correct |
2 ms |
540 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
2 ms |
596 KB |
Output is correct |
30 |
Correct |
2 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
596 KB |
Output is correct |
32 |
Correct |
2 ms |
584 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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 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 |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
360 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
520 KB |
Output is correct |
20 |
Correct |
2 ms |
596 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
2 ms |
584 KB |
Output is correct |
23 |
Correct |
2 ms |
592 KB |
Output is correct |
24 |
Correct |
2 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
536 KB |
Output is correct |
26 |
Correct |
2 ms |
588 KB |
Output is correct |
27 |
Correct |
2 ms |
540 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
2 ms |
596 KB |
Output is correct |
30 |
Correct |
2 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
596 KB |
Output is correct |
32 |
Correct |
2 ms |
584 KB |
Output is correct |
33 |
Correct |
320 ms |
33804 KB |
Output is correct |
34 |
Correct |
327 ms |
35264 KB |
Output is correct |
35 |
Correct |
323 ms |
33996 KB |
Output is correct |
36 |
Correct |
330 ms |
34732 KB |
Output is correct |
37 |
Correct |
354 ms |
35832 KB |
Output is correct |
38 |
Correct |
328 ms |
35336 KB |
Output is correct |
39 |
Correct |
318 ms |
34060 KB |
Output is correct |
40 |
Correct |
299 ms |
34032 KB |
Output is correct |
41 |
Correct |
321 ms |
34412 KB |
Output is correct |
42 |
Correct |
304 ms |
34252 KB |
Output is correct |
43 |
Correct |
329 ms |
34084 KB |
Output is correct |
44 |
Correct |
318 ms |
33188 KB |
Output is correct |
45 |
Correct |
337 ms |
33500 KB |
Output is correct |
46 |
Correct |
313 ms |
33212 KB |
Output is correct |
47 |
Correct |
196 ms |
24496 KB |
Output is correct |
48 |
Correct |
189 ms |
24404 KB |
Output is correct |
49 |
Correct |
353 ms |
35064 KB |
Output is correct |
50 |
Correct |
319 ms |
35052 KB |
Output is correct |
51 |
Correct |
324 ms |
35072 KB |
Output is correct |
52 |
Correct |
358 ms |
34984 KB |
Output is correct |
53 |
Correct |
324 ms |
35088 KB |
Output is correct |