# pragma GCC optimize ("O3")
# pragma GCC optimize ("Ofast")
# pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define MEM 222222
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define pf push_front
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz size()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
typedef pair<pi, pi> pii;
const ll MOD = 1e18;
const ll INF = 2e9+7;
const long double Pi = 3.141592;
ll gp(ll a, ll b){
return ((a*b)%MOD+MOD)%MOD;
}
ll t,n;
ll b[MEM];
pi a[MEM];
ll ans[MEM], c1[MEM], c2[MEM];
signed main(){
sanic; cin.tie(0); cout.tie(0);
cin >> n;
for(ll i=1; i<=n+1; i++){
cin >> a[i].x;
a[i].y = i;
}
for(int i=1; i<=n; i++)
cin >> b[i];
sort(a+1,a+n+2);
sort(b+1,b+n+1);
for(int i=1; i<=n; i++){
c1[i] = a[i].x-b[i];
c2[i] = a[i+1].x-b[i];
//cout << c1[i] << ' ' << c2[i] << '\n';
}
for(int i=1; i<=n; i++)
c1[i] = max(c1[i], c1[i-1]);
for(int i=n; i>0; i--)
c2[i] = max(c2[i], c2[i+1]);
for(int i=1; i<=n+1; i++){
ll j = a[i].y;
ans[j] = max(c1[j-1], c2[j]);
// << j << ' ' << ans[j] << '\n';
}
for(int i=1; i<=n+1; i++)
cout << ans[i] << ' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |