#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define pa pair<ll, ll>
#define fi first
#define se second
#define bit(mask, j) ((mask >> j) & 1)
#define t_test int t;cin >> t;while(t--)
const ll mod = 1e9 + 7;
const ll INF = 1e18;
inline void adm(ll &x){if(x>=mod)x%=mod;else if(x<0)x+=mod;}
//--------------------------------------------------------------------
const ll N = 1e6 + 10;
ll b[N];
pa a[N];
ll n;
ll c[N];
ll suf[N], pre[N];
void hbmt() {
cin >> n;
FOR(i, 1, n + 1) {
cin >> a[i].fi;
a[i].se = i;
}
sort(a + 1, a + n + 2);
FOR(i, 1, n) {
cin >> b[i];
}
sort(b + 1, b + n + 1);
FOR(i, 1, n + 1) {
pre[i] = max(pre[i - 1], a[i].fi - b[i]);
}
FORD(i, n + 1, 2) {
suf[i] = max(suf[i + 1], a[i].fi - b[i - 1]);
}
FOR(i, 1, n + 1) {
c[a[i].se] = max(pre[i - 1], suf[i + 1]);
}
FOR(i, 1, n + 1) cout << c[i] << ' ';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen("hbmt.inp", "r")) {
freopen("hbmt.inp", "r", stdin);
freopen("hbmt.out", "w", stdout);
}
// t_test
hbmt();
return 0;
}
Compilation message (stderr)
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
50 | freopen("hbmt.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | freopen("hbmt.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |