Submission #222459

#TimeUsernameProblemLanguageResultExecution timeMemory
222459astoriaJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
315 ms10872 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; pair<int,int> a[200005]; for(int i=0; i<n+1; i++){ cin>>a[i].first; a[i].second = i;} int b[200005]; for(int i=0; i<n; i++) cin>>b[i]; sort(b,b+n); sort(a,a+n+1); int eq[200005],abv[200005]; for(int i=0; i<n; i++){ eq[i] = max(a[i].first-b[i],0); abv[i] = max(a[i+1].first-b[i],0); } int ans[200005]; int mx=0; for(int i=0; i<n; i++) mx = max(mx, eq[i]); ans[a[n].second] = mx; for(int i=n-1; i>=0; i--){ mx = max(mx, abv[i]); ans[a[i].second] = mx; } for(int i=0; i<=n; i++) cout<<ans[i]<<' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...