Submission #566739

#TimeUsernameProblemLanguageResultExecution timeMemory
566739milisavJust Long Neckties (JOI20_ho_t1)C++14
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> #define maxn 500000 using namespace std; int n; int a[maxn]; int b[maxn]; int pref[maxn]; int suf[maxn]; int main() { scanf("%d",&n); for(int i=1;i<=n+1;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++) scanf("%d",&b[i]); sort(a+1,a+(n+2)); sort(b+1,b+(n+1)); for(int i=1;i<=n;i++) pref[i]=max(pref[i-1],max(a[i]-b[i],0)); for(int i=n;i>=1;i--) suf[i]=max(suf[i+1],max(a[i+1]-b[i],0)); for(int i=1;i<=n+1;i++) { printf("%d ",max(pref[i-1],suf[i])); } return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
ho_t1.cpp:11:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(int i=1;i<=n+1;i++) scanf("%d",&a[i]);
      |                             ~~~~~^~~~~~~~~~~~
ho_t1.cpp:12:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(int i=1;i<=n;i++) scanf("%d",&b[i]);
      |                           ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...