#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
/**zagaro & lauren <3**/
#define mod 1000000007 //1e9 + 7
#define pi acos(-1)
#define wl while
#define str string
#define ENDL "\n"
#define sal ' '
#define tp_set ll
#define prc(n) cout.precision(n);cout<<fixed;
#define ord_set tree<tp_set, null_type, less<tp_set>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef bool bl;
typedef char car;
using namespace std;
using namespace __gnu_pbds;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n;
cin>>n;
vector<pair<ll,ll> > vec(n+2);
vector<ll> res(n+2);
vector<ll> vc(n+1);
vector<ll> prf(n+1, 0);
vector<ll> suf(n+2, 0);
for(int i=1;i<=n+1;i++){
cin>>vec[i].first;
vec[i].second = i;
}
for(int i=1;i<=n;i++)cin>>vc[i];
sort(vec.begin(), vec.end());
sort(vc.begin(), vc.end());
for(int i=1;i<=n;i++)prf[i] = max(prf[i-1], max(vec[i].first-vc[i], ll (0)));
for(int i=n;i>=1;i--)suf[i] = max(suf[i+1], max(vec[i+1].first-vc[i], ll (0)));
for(int i=1;i<=n+1;i++)res[vec[i].second] = max(prf[i-1], suf[i]);
for(int i=1;i<=n+1;i++)cout<<res[i]<<sal;
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... |