#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
const int mod = 998244353;
void solve() {
int n, s;
cin >> n;
vector <int> a(n);
vector <pair <int, int> > v(n + 1);
for (int i = 0; i <= n; i++) {
int b;
cin >> b;
v[i] = {b, i};
}
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
sort(v.begin(), v.end());
vector <int> ans(n + 1), gith(n + 2), lera(n + 2), mx(n + 1);
gith[0] = v[0].f - a[0];
for (int i = 1; i < n; i++) {
gith[i] = max(gith[i-1], v[i].f - a[i]);
}
ans[v[0].s] = v[1].f - a[0];
for (int i = n; i >= 1; i--) {
lera[i] = max(lera[i + 1], v[i].f - a[i-1]);
ans[v[i].s] = max(lera[i + 1], gith[i - 1]);
}
for (int i = 0 ; i < n + 1; i++) {
cout << ans[i] << " ";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}
Compilation message
ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:5:11: warning: unused variable 'second' [-Wunused-variable]
5 | #define s second
| ^~~~~~
ho_t1.cpp:11:12: note: in expansion of macro 's'
11 | int n, s;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |