# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771964 | Trisanu_Das | Just Long Neckties (JOI20_ho_t1) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
using namespace std;
//limit definitions
#define N 200050
int b[N], p[N], s[N], ans[N];
pair<int, int> a[N];
int main(){
int n; cin >> n;
for(int i = 1; i < n + 2; i++) cin >> a[i].ff, a[i].ss = i;
for(int i = 1; i < n + 1; i++) cin >> b[i];
sort(a, a + n + 2), sort(b, b + n + 1);
for(int i = 1; i < n + 1; i++) p[i] = max(p[i - 1], a[i].ff - b[i]);
for(int i = n; i > 0; i--) s[i] = max(s[i + 1], a[i + 1].ff - b[i]);
for(int i = 0; i < n + 1; i++) ans[a[i + 1].ss] = max(p[i], s[i + 1]);
for(int i = 1; i < n + 2; i++) cout << ans[i] << '\n';
}