Submission #625469

#TimeUsernameProblemLanguageResultExecution timeMemory
625469AugustynJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
133 ms10836 KiB
#include<bits/stdc++.h> using namespace std; int n,suf[200002],pref[200002]; pair<int,int>a[200002]; int b[200001],odp[200002]; int main() { scanf("%d",&n); for(int i=0;i<=n;++i) { scanf("%d",&a[i].first); a[i].second=i; } for(int i=0;i<n;++i) { scanf("%d",&b[i]); } sort(a,a+(n+1)); sort(b,b+n); for(int i=n-1;i>=0;--i) suf[i]=max(suf[i+1],a[i+1].first-b[i]); pref[0]=max(0,a[0].first-b[0]); for(int i=1;i<n;++i) pref[i]=max(pref[i-1],a[i].first-b[i]); for(int i=1;i<=n;++i) odp[a[i].second]=max(pref[i-1],suf[i]); odp[a[0].second]=suf[0]; for(int i=0;i<=n;++i) printf("%d ",odp[i]); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
ho_t1.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d",&a[i].first);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
ho_t1.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d",&b[i]);
      |   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...