Submission #925202

#TimeUsernameProblemLanguageResultExecution timeMemory
925202huutuanJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
79 ms11604 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N=2e5+10; pair<int, int> a[N]; int b[N], res[N], n, pf[N], sf[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i=1; i<=n+1; ++i) cin >> a[i].first, a[i].second=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) pf[i]=max(pf[i-1], max(a[i].first-b[i], 0ll)); for (int i=n; i>=1; --i) sf[i]=max(sf[i+1], max(a[i+1].first-b[i], 0ll)); for (int i=1; i<=n+1; ++i) res[a[i].second]=max(pf[i-1], sf[i]); for (int i=1; i<=n+1; ++i) cout << res[i] << " \n"[i==n+1]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...