#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n; cin >> n;
vector<ll> wolne(n + 1);
for(int i = 0; i < n + 1; i++) {
cin >> wolne[i];
}
vector<ll> ter(n);
for(int i = 0; i < n; i++) {
cin >> ter[i];
}
sort(wolne.begin(), wolne.end());
sort(ter.begin(), ter.end());
vector<pair<ll, ll>> pary(n);
for(int i = 0; i < n; i++) {
pary[i] = {wolne[i] - ter[i], wolne[i + 1] - ter[i]};
//cout << "i: " << wolne[i] - ter[i] << " " << wolne[i + 1] - ter[i] << "\n";
}
vector<ll> sp1(n);
//vector<ll> sp2(n);
//vector<ll> sp1r(n);
vector<ll> sp2r(n);
sp1[0] = pary[0].first;
//sp2[0] = pary[0].second;
//sp1r[n - 1] = pary[n - 1].first;
sp2r[n - 1] = pary[n - 1].second;
for(int i = 1; i < n; i++) {
sp1[i] = max(sp1[i - 1], pary[i].first);
//sp2[i] = max(sp2[i - 1], pary[i].second);
}
for(int i = n - 2; i >= 0; i--) {
//sp1r[i] = max(sp1r[i + 1], pary[i].first);
sp2r[i] = max(sp2r[i + 1], pary[i].second);
}
reverse(sp1.begin(), sp1.end());
reverse(sp2r.begin(), sp2r.end());
// for(int i = 0; i < n; i++) {
// cout << sp1[i] << " " << sp2r[i] << '\n';
// }
//cout << "out\n";
cout << sp2r[n - 1] << '\n';
for(int i = n - 2; i >= 0; i--) {
cout << max(sp1[i], sp2r[i]) << '\n';
}
cout << sp1[0] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |