Submission #390709

#TimeUsernameProblemLanguageResultExecution timeMemory
390709wildturtleJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
259 ms15596 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll a,b,c,d,i,e,f,g,n,m,k,l; ll B[500005],C[500005],D[500005],ans[500005]; pair <ll,ll> A[500005]; string s[5003]; int main() { cin>>n; for(ll i=1;i<=n+1;i++) { cin>>A[i].first; A[i].second=i; } sort(A+1,A+1+n+1); for(ll i=1;i<=n;i++) { cin>>B[i]; } sort(B+1,B+1+n); for(ll i=1;i<=n;i++) { C[i]=max(C[i-1],max(0ll,A[i].first-B[i])); } for(ll i=n;i>=1;i--) { D[i]=max(D[i+1],max(0ll,A[i+1].first-B[i])); //cout<<D[i]<<" "; } //cout<<endl; for(ll i=1;i<=n+1;i++) { //cout<<C[i-1]<<" "<<D[i]<<endl; ans[A[i].second]=max(C[i-1],D[i]); } for(ll i=1;i<=n+1;i++) { cout<<ans[i]<<" "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...