#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< int, int > ii;
typedef pair< int, ii > iii;
typedef vector< int > vi;
typedef vector< ii > vii;
typedef vector< iii > viii;
typedef vector< vi > vvi;
typedef vector< vii > vvii;
typedef vector< viii > vviii;
#define hdp 1e9+7
#define MAX LLONG_MAX
#define st first
#define nd second
int main(){
int n; cin >> n;
vi a(n+1); for(int i=0; i<=n; i++) cin >> a[i];
vi a0 = a, b(n); for(int i=0; i<n; i++) cin >> b[i];
sort(a.begin(), a.end()); sort(b.begin(), b.end());
unordered_map<int, int> idx; for(int i=0; i<=n; i++) idx[a[i]] = i;
vi dpl(n + 1), dpr(n + 1);
for(int i=1; i<=n; i++){
dpl[i] = max(0, a[i - 1] - b[i - 1]);
dpr[i - 1] = max(0, a[i] - b[i - 1]);
}
for(int i=1; i<=n; i++) dpl[i] = max(dpl[i], dpl[i - 1]);
for(int i=n; i>=1; i--) dpr[i - 1] = max(dpr[i - 1], dpr[i]);
for(int i=0; i<=n; i++){
if(i != 0) cout << " ";
int trace = idx[a0[i]];
cout << max(dpl[trace], dpr[trace]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 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 |
3 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
3 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
440 KB |
Output is correct |
19 |
Correct |
2 ms |
436 KB |
Output is correct |
20 |
Correct |
2 ms |
436 KB |
Output is correct |
21 |
Correct |
2 ms |
336 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 |
2 ms |
440 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 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 |
3 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
3 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
440 KB |
Output is correct |
19 |
Correct |
2 ms |
436 KB |
Output is correct |
20 |
Correct |
2 ms |
436 KB |
Output is correct |
21 |
Correct |
2 ms |
336 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 |
2 ms |
440 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
444 KB |
Output is correct |
33 |
Correct |
201 ms |
14652 KB |
Output is correct |
34 |
Correct |
217 ms |
15260 KB |
Output is correct |
35 |
Correct |
195 ms |
14820 KB |
Output is correct |
36 |
Correct |
195 ms |
15276 KB |
Output is correct |
37 |
Correct |
237 ms |
15804 KB |
Output is correct |
38 |
Correct |
199 ms |
15476 KB |
Output is correct |
39 |
Correct |
212 ms |
14584 KB |
Output is correct |
40 |
Correct |
201 ms |
14448 KB |
Output is correct |
41 |
Correct |
209 ms |
14644 KB |
Output is correct |
42 |
Correct |
214 ms |
14512 KB |
Output is correct |
43 |
Correct |
213 ms |
14544 KB |
Output is correct |
44 |
Correct |
195 ms |
14152 KB |
Output is correct |
45 |
Correct |
198 ms |
14148 KB |
Output is correct |
46 |
Correct |
190 ms |
14088 KB |
Output is correct |
47 |
Correct |
148 ms |
6832 KB |
Output is correct |
48 |
Correct |
146 ms |
6836 KB |
Output is correct |
49 |
Correct |
211 ms |
14872 KB |
Output is correct |
50 |
Correct |
208 ms |
14864 KB |
Output is correct |
51 |
Correct |
225 ms |
14840 KB |
Output is correct |
52 |
Correct |
203 ms |
14852 KB |
Output is correct |
53 |
Correct |
207 ms |
14808 KB |
Output is correct |