제출 #1280905

#제출 시각아이디문제언어결과실행 시간메모리
1280905dhuyyyyJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
72 ms13128 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;

using ll = long long;
using ii = pair<int, int>;
using aa = array<int,3>;

const int N = 2e5+5;

int n;

int pre[N], suf[N], res[N];

ii a[N], b[N];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n + 1; i++){
        cin >> a[i].fi;
        a[i].se = i;
    }
    for (int i = 1; i <= n; i++){
        cin >> b[i].fi;
        b[i].se = i;
    }
    sort(a+1,a+2+n);
    sort(b+1,b+1+n);
    for (int i = 1; i <= n; i++){
        pre[i] = max(pre[i-1],max(a[i].fi - b[i].fi,0LL));
    }
    for (int i = n + 1; i >= 2; i--){
        suf[i] = max(suf[i + 1],max(a[i].fi - b[i-1].fi,0LL));
    }
    for (int i = 1; i <= n + 1; i++){
        res[a[i].se] = max(pre[i-1],suf[i+1]);
    }
    for (int i = 1; i <= n + 1; i++) cout << res[i] << ' ';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...