Submission #848296

#TimeUsernameProblemLanguageResultExecution timeMemory
848296dungzJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
77 ms18772 KiB
#pragma GCC optimize ("O2") #include<bits/stdc++.h> using namespace std; #define ll long long #define fo(i,a,b) for(ll i=a;i<=b;++i) #define ff(i,a,b) for(ll i=a;i>=b;--i) #define fi first #define se second #define endl '\n' #define task "task" #define task "task" #define prll pair<ll,ll> #define pb push_back #define ld long double const ll MIN=-1e18,MAX=1e18,MOD=1e9+7; prll b[200005]; ll c[200005],mx1[200005],mx2[200005],h1[200005],h2[200005],ans[200005]; int main() { // #ifndef ONLINE_JUDGE // freopen (task".inp", "r", stdin); // freopen (task".out", "w", stdout); // #endif ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); ll a; cin>>a; fo(i,1,a+1) { cin>>b[i].fi; b[i].se=i; } fo(i,1,a) { cin>>c[i]; } sort(b+1,b+2+a); sort(c+1,c+1+a); fo(i,1,a) { h1[i]=max((ll)0,b[i].fi-c[i]); h2[i]=max((ll)0,b[i+1].fi-c[i]); } fo(i,1,a) { mx1[i]=max(h1[i],mx1[i-1]); } ff(i,a,1) { mx2[i]=max(h2[i],mx2[i+1]); } fo(i,1,a+1) { ans[b[i].se]=max(mx1[i-1],mx2[i]); } fo(i,1,a+1) cout<<ans[i]<<" "; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...