#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
main(){
int n;
cin >> n;
ii arr[n+1];
for (int i = 0; i < n+1; i++) {
cin >> arr[i].first;
arr[i].second = i;
}
int arr2[n];
for (int i = 0; i < n; i++) cin >> arr2[i];
sort(arr,arr+n+1);
sort(arr2,arr2+n);
int ans[n+1];
ans[n] = 0;
multiset<int> s;
for (int i = 0; i < n; i++) s.insert(max(arr[i].first-arr2[i],0LL));
ans[arr[n].second] = *(--s.end());
for (int i = n-1; i >= 0; i--){
s.erase(s.find(max(arr[i].first-arr2[i],0LL)));
s.insert(max(arr[i+1].first-arr2[i],0LL));
ans[arr[i].second] = *(--s.end());
}
for (int i = 0; i < n+1; i++) cout << ans[i] << " ";
}
Compilation message
ho_t1.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
256 KB |
Output is correct |
17 |
Correct |
8 ms |
512 KB |
Output is correct |
18 |
Correct |
8 ms |
512 KB |
Output is correct |
19 |
Correct |
8 ms |
512 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
8 ms |
512 KB |
Output is correct |
22 |
Correct |
8 ms |
512 KB |
Output is correct |
23 |
Correct |
8 ms |
512 KB |
Output is correct |
24 |
Correct |
7 ms |
512 KB |
Output is correct |
25 |
Correct |
9 ms |
512 KB |
Output is correct |
26 |
Correct |
7 ms |
512 KB |
Output is correct |
27 |
Correct |
7 ms |
512 KB |
Output is correct |
28 |
Correct |
7 ms |
512 KB |
Output is correct |
29 |
Correct |
7 ms |
512 KB |
Output is correct |
30 |
Correct |
7 ms |
512 KB |
Output is correct |
31 |
Correct |
7 ms |
512 KB |
Output is correct |
32 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
256 KB |
Output is correct |
17 |
Correct |
8 ms |
512 KB |
Output is correct |
18 |
Correct |
8 ms |
512 KB |
Output is correct |
19 |
Correct |
8 ms |
512 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
8 ms |
512 KB |
Output is correct |
22 |
Correct |
8 ms |
512 KB |
Output is correct |
23 |
Correct |
8 ms |
512 KB |
Output is correct |
24 |
Correct |
7 ms |
512 KB |
Output is correct |
25 |
Correct |
9 ms |
512 KB |
Output is correct |
26 |
Correct |
7 ms |
512 KB |
Output is correct |
27 |
Correct |
7 ms |
512 KB |
Output is correct |
28 |
Correct |
7 ms |
512 KB |
Output is correct |
29 |
Correct |
7 ms |
512 KB |
Output is correct |
30 |
Correct |
7 ms |
512 KB |
Output is correct |
31 |
Correct |
7 ms |
512 KB |
Output is correct |
32 |
Correct |
7 ms |
512 KB |
Output is correct |
33 |
Correct |
404 ms |
20356 KB |
Output is correct |
34 |
Correct |
415 ms |
21288 KB |
Output is correct |
35 |
Correct |
383 ms |
20600 KB |
Output is correct |
36 |
Correct |
428 ms |
21112 KB |
Output is correct |
37 |
Correct |
427 ms |
21880 KB |
Output is correct |
38 |
Correct |
411 ms |
21496 KB |
Output is correct |
39 |
Correct |
431 ms |
20472 KB |
Output is correct |
40 |
Correct |
444 ms |
20488 KB |
Output is correct |
41 |
Correct |
440 ms |
20664 KB |
Output is correct |
42 |
Correct |
433 ms |
20472 KB |
Output is correct |
43 |
Correct |
429 ms |
20472 KB |
Output is correct |
44 |
Correct |
396 ms |
19832 KB |
Output is correct |
45 |
Correct |
383 ms |
19960 KB |
Output is correct |
46 |
Correct |
386 ms |
19832 KB |
Output is correct |
47 |
Correct |
370 ms |
20600 KB |
Output is correct |
48 |
Correct |
383 ms |
20472 KB |
Output is correct |
49 |
Correct |
448 ms |
21112 KB |
Output is correct |
50 |
Correct |
435 ms |
21240 KB |
Output is correct |
51 |
Correct |
449 ms |
20984 KB |
Output is correct |
52 |
Correct |
448 ms |
20984 KB |
Output is correct |
53 |
Correct |
503 ms |
21112 KB |
Output is correct |