#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18;
const ll mod = 1e9 + 7;
pll a[N];
ll b[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
for(ll i = 0; i <= n; i++){
cin >> a[i].F;
a[i].S = i;
}
for(ll i = 0; i < n; i++){
cin >> b[i];
}
sort(a, a + n + 1);
sort(b, b + n);
for(ll i = 0; i <= n; i++){
ll plus = 0, mx = 0;
for(ll j = 0; j < n; j++){
if(a[j].S == i) plus = 1;
mx = max(mx, a[j + plus].F - b[j]);
//cout << a[j + plus].F << " " << b[j] << endl;
}
cout << mx << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |