Submission #201457

#TimeUsernameProblemLanguageResultExecution timeMemory
201457Alexa2001Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
162 ms7800 KiB
#include <bits/stdc++.h> using namespace std; const int Nmax = 2e5 + 5; int dp1[Nmax], dp2[Nmax], A[Nmax], B[Nmax], ans[Nmax]; pair<int,int> ord[Nmax]; int n; int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); cin.tie(0); cin >> n; int i; for(i=1; i<=n+1; ++i) cin >> ord[i].first, ord[i].second = i; for(i=1; i<=n; ++i) cin >> B[i]; sort(B+1, B+n+1); sort(ord+1, ord+n+2); for(i=1; i<=n+1; ++i) A[i] = ord[i].first; for(i=1; i<=n; ++i) dp1[i] = max(dp1[i-1], A[i] - B[i]); for(i=n+1; i>=2; --i) dp2[i] = max(dp2[i+1], A[i] - B[i-1]); for(i=1; i<=n+1; ++i) ans[ord[i].second] = max(dp1[i-1], dp2[i+1]); for(i=1; i<=n+1; ++i) cout << ans[i] << ' '; cout << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...