Submission #929095

#TimeUsernameProblemLanguageResultExecution timeMemory
929095haru09Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
77 ms10832 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define task "code" const int ar=2e5+5; const ll mod=1e9+7; int n; pair<int,int> a[ar]; int b[ar]; int pre[ar]; int suf[ar]; int ans[ar]; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin>>n; for (int i=1;i<=n+1;i++) { cin>>a[i].fi; a[i].se=i; } for (int i=1;i<=n;i++) cin>>b[i]; sort(a+1,a+n+2); sort(b+1,b+n+1); for (int i=1;i<=n;i++) pre[i]=max({0,pre[i-1],a[i].fi-b[i]}); for (int i=n;i>=1;i--) suf[i]=max({0,suf[i+1],a[i+1].fi-b[i]}); for (int i=1;i<=n+1;i++) ans[a[i].se]=max(pre[i-1],suf[i]); for (int i=1;i<=n+1;i++) cout<<ans[i]<<' '; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...