This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
//#pragma expected_value
//#pragma isolated_call
//#pragma disjoint
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define setpre(i) setprecision(i)<<fixed
#define foru(i, a, b) for(int i=a;i<=b;i++)
#define ford(i, a, b) for(int i=a;i>=b;i--)
#define mp make_pair
#define moo cout<<"moo "
#define fi first
#define se second
ll lmod = 1e9 + 7;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
ii arr[200002];
int a[200001];
int maxpref[2][200002];
int pos[200002];
int main(){
// freopen("input.inp", "r", stdin);
// freopen("output.out", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
foru(i, 1, n + 1){
int x; cin >> x;
arr[i] = mp(x, i);
}
foru(i, 1, n) cin >> a[i];
sort(arr + 1, arr + n + 2);
sort(a + 1, a + n + 1);
foru(i, 1, n + 1) pos[arr[i].se] = i;
foru(i, 1, n) maxpref[0][i] = max(maxpref[0][i - 1], arr[i].fi - a[i]);
ford(i, n + 1, 1) maxpref[1][i] = max(maxpref[1][i + 1], arr[i].fi - a[i - 1]);
// foru(i, 0, 1){
// foru(j, 1, n + 1) cout << maxpref[i][j] << " ";
// cout << endl;
// }
foru(i, 1, n + 1) cout << max(maxpref[0][pos[i] - 1], maxpref[1][pos[i] + 1]) << " ";
// fclose(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... |