Submission #545519

#TimeUsernameProblemLanguageResultExecution timeMemory
545519status_codingJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
222 ms9400 KiB
#include <bits/stdc++.h> using namespace std; int n; pair<int, int> a[200005]; int b[200005]; int dpL[200005], dpR[200005]; int ans[200005]; int main() { cin>>n; for(int i=1; i<=n+1; i++) { cin>>a[i].first; a[i].second = i; } sort(a+1, a+n+2); for(int i=1; i<=n; i++) cin>>b[i]; sort(b+1, b+n+1); for(int i=1; i<=n; i++) dpL[i] = max(dpL[i-1], max(a[i].first - b[i], 0)); for(int i=n+1; i>=2; i--) dpR[i] = max(dpR[i+1], max(a[i].first - b[i-1], 0)); for(int i=1; i<=n+1; i++) ans[ a[i].second ] = max(dpL[i-1], dpR[i+1]); for(int i=1; i<=n+1; i++) cout<<ans[i]<<' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...