Submission #787303

#TimeUsernameProblemLanguageResultExecution timeMemory
787303winter0101Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
88 ms10796 KiB
#include<bits/stdc++.h> using namespace std; #define all(fl) fl.begin(),fl.end() #define pb push_back #define fi first #define se second #define for1(i,j,k) for(int i=j;i<=k;i++) #define for2(i,j,k) for(int i=j;i>=k;i--) #define for3(i,j,k,l) for(int i=j;i<=k;i+=l) #define lb lower_bound #define ub upper_bound #define sz(a) (int)a.size() #define pii pair<int,int> #define pli pair<long long,int> #define gcd __gcd #define lcm(x,y) x*y/__gcd(x,y) #define pil pair<int,long long> pii a[200009]; int b[200009]; int p[200009],s[200009]; int ans[200009]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); //freopen("temp.INP","r",stdin); //freopen("temp.OUT","w",stdout); int n; cin>>n; for1(i,1,n+1){ cin>>a[i].fi; a[i].se=i; } for1(i,1,n)cin>>b[i]; sort(a+1,a+1+n+1); sort(b+1,b+1+n); for1(i,1,n){ p[i]=max(p[i-1],max(a[i].fi-b[i],0)); } for2(i,n+1,2){ s[i]=max(s[i+1],max(a[i].fi-b[i-1],0)); } for1(i,1,n+1){ ans[a[i].se]=max(p[i-1],s[i+1]); } for1(i,1,n+1)cout<<ans[i]<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...