#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
vector<ll> ludzie;
vector<ll> szef;
ll p1;
int n;
cin >> n;
for (int i = 0; n >= i; i++) {
cin >> p1;
szef.push_back(p1);
}
for (int i = 0; n > i; i++) {
cin >> p1;
ludzie.push_back(p1);
}
sort(ludzie.begin(), ludzie.end());
sort(szef.begin(), szef.end());
vector<ll> pref(n+2);
vector<ll> suf(n + 2);
pref[0] = (ll)0;
suf[n + 1] = (ll)0;
for (int i = 1; n >= i; i++) {
pref[i] = max(pref[i - 1], szef[i - 1] - ludzie[i - 1]);
//cout << i << " " << pref[i] << "\n";
}
for (int i = n; i > 0; i--) {
suf[i] = max(suf[i + 1], szef[i] - ludzie[i - 1]);
//cout << i << " " << suf[i] << "\n";
}
for (int i = 1; n + 1 >= i; i++) {
cout << max(pref[i - 1], suf[i]) << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |