#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mx = 2e5+5;
int n;
pair<int,int> a[mx];
int b[mx];
int d[mx], rd[mx];
int ans[mx];
signed main() {
cin.tie(0);ios::sync_with_stdio(0);
cin >> n;
for (int i=0;i<=n;i++) {
cin >> a[i].first;
a[i].second = i;
}
for (int i=0;i<n;i++) {
cin >> b[i];
}
sort(a,a+n+1);
sort(b,b+n);
multiset<int> st;
for (int i=0;i<n;i++) {
st.insert(max(a[i+1].first-b[i],0LL));
// cout << max(a[i+1].first-b[i],0LL) << "\n";
}
ans[a[0].second] = *--st.end();
// cout << a[0].second << " " << st.size() << "\n";
for (int i=0;i<n;i++) {
st.erase(st.find(max(a[i+1].first-b[i], 0LL)));
// cout << max(a[i+1].first-b[i], 0LL) << " " << max(a[i].first-b[i], 0LL) << "\n";
st.insert(max(a[i].first-b[i],0LL));
// cout << a[i].second << "owo\n";
ans[a[i+1].second] = *--st.end();
}
for (int i=0;i<=n;i++) {
cout << ans[i] << " ";
}
cout << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
2 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2392 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
2 ms |
2564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
2 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
2 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2392 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
2 ms |
2564 KB |
Output is correct |
33 |
Correct |
136 ms |
18004 KB |
Output is correct |
34 |
Correct |
153 ms |
18516 KB |
Output is correct |
35 |
Correct |
131 ms |
18192 KB |
Output is correct |
36 |
Correct |
139 ms |
18520 KB |
Output is correct |
37 |
Correct |
147 ms |
19124 KB |
Output is correct |
38 |
Correct |
138 ms |
18840 KB |
Output is correct |
39 |
Correct |
181 ms |
17748 KB |
Output is correct |
40 |
Correct |
183 ms |
17744 KB |
Output is correct |
41 |
Correct |
181 ms |
18004 KB |
Output is correct |
42 |
Correct |
184 ms |
17896 KB |
Output is correct |
43 |
Correct |
183 ms |
17760 KB |
Output is correct |
44 |
Correct |
123 ms |
17232 KB |
Output is correct |
45 |
Correct |
126 ms |
17476 KB |
Output is correct |
46 |
Correct |
125 ms |
17236 KB |
Output is correct |
47 |
Correct |
122 ms |
17584 KB |
Output is correct |
48 |
Correct |
126 ms |
17584 KB |
Output is correct |
49 |
Correct |
191 ms |
18260 KB |
Output is correct |
50 |
Correct |
190 ms |
18264 KB |
Output is correct |
51 |
Correct |
189 ms |
18196 KB |
Output is correct |
52 |
Correct |
191 ms |
18260 KB |
Output is correct |
53 |
Correct |
188 ms |
18256 KB |
Output is correct |