#include <bits/stdc++.h>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int32_t n;
std::cin >> n;
std::vector< int32_t > a(n + 1);
for(int32_t i = 0; i < n + 1; i++) {
std::cin >> a[i];
}
std::vector< int32_t > b(n);
for(int32_t i = 0; i < n; i++) {
std::cin >> b[i];
}
std::sort(a.begin(), a.end());
std::sort(b.begin(), b.end());
std::vector< int32_t > prefMax(n), suffMax(n);
for(int32_t i = 0; i < n; i++) {
if(i != 0) {
prefMax[i] = prefMax[i - 1];
}
else {
prefMax[i] = 0;
}
prefMax[i] = std::max(prefMax[i], a[i] - b[i]);
}
for(int32_t i = n - 1; i >= 0; i--) {
if(i != n - 1) {
suffMax[i] = suffMax[i + 1];
}
else {
suffMax[i] = 0;
}
suffMax[i] = std::max(suffMax[i], a[i + 1] - b[i]);
}
std::cout << suffMax[0] << " ";
for(int32_t i = 0; i < n - 1; i++) {
std::cout << std::max(prefMax[i], suffMax[i + 1]) << " ";
}
std::cout << prefMax[n - 1] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |