#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
int n;
int b[N], odd[N], ans[N];
vector<pair<int, int>> a;
void read() {
cin >> n;
for(int i = 0; i <= n; i++) {
int x; cin >> x;
a.push_back({x, i});
}
sort(a.begin(), a.end());
for(int i = 0; i < n; i++)
cin >> b[i];
sort(b, b+n);
}
void solve() {
for(int i = 0; i < n; i++) {
odd[i] = max(0, a[i+1].first - b[i]);
}
for(int i = 0; i < n; i++) {
int& mx = ans[a[i].second] = 0;
for(int j = 0; j < n; j++)
mx = max(mx, odd[j]);
odd[i] = max(0, a[i].first - b[i]);
}
int& mx = ans[a[n].second] = 0;
for(int j = 0; j < n; j++)
mx = max(mx, odd[j]);
for(int i = 0; i < n+1; i++)
cout << ans[i] << " \n"[i==n];
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
read();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
8 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
9 ms |
512 KB |
Output is correct |
18 |
Correct |
8 ms |
384 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 |
8 ms |
512 KB |
Output is correct |
25 |
Correct |
10 ms |
512 KB |
Output is correct |
26 |
Correct |
9 ms |
512 KB |
Output is correct |
27 |
Correct |
9 ms |
640 KB |
Output is correct |
28 |
Correct |
10 ms |
512 KB |
Output is correct |
29 |
Correct |
8 ms |
512 KB |
Output is correct |
30 |
Correct |
9 ms |
512 KB |
Output is correct |
31 |
Correct |
10 ms |
512 KB |
Output is correct |
32 |
Correct |
10 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
8 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
9 ms |
512 KB |
Output is correct |
18 |
Correct |
8 ms |
384 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 |
8 ms |
512 KB |
Output is correct |
25 |
Correct |
10 ms |
512 KB |
Output is correct |
26 |
Correct |
9 ms |
512 KB |
Output is correct |
27 |
Correct |
9 ms |
640 KB |
Output is correct |
28 |
Correct |
10 ms |
512 KB |
Output is correct |
29 |
Correct |
8 ms |
512 KB |
Output is correct |
30 |
Correct |
9 ms |
512 KB |
Output is correct |
31 |
Correct |
10 ms |
512 KB |
Output is correct |
32 |
Correct |
10 ms |
512 KB |
Output is correct |
33 |
Execution timed out |
1090 ms |
7916 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |