Submission #206773

#TimeUsernameProblemLanguageResultExecution timeMemory
206773ShelbyJust Long Neckties (JOI20_ho_t1)C++11
0 / 100
5 ms376 KiB
#include <bits/stdc++.h> #define MAXN 200005 using namespace std; int m[MAXN],s[MAXN],mxm[MAXN],mxs[MAXN],c[MAXN],b[MAXN]; pair<int,int> a[MAXN]; int main() { int n,i,poz; scanf("%d",&n); for(i=0;i<=n;i++) { scanf("%d",&a[i].first); a[i].second=i; } for(i=0;i<n;i++) scanf("%d",&b[i]); sort(a,a+n+1); sort(b,b+n); for(i=0;i<n;i++) m[i]=a[i].first-b[i]; for(i=1;i<=n;i++) s[i]=a[i].first-b[i-1]; mxm[0]=m[0]; for(i=1;i<n;i++) mxm[i]=max(mxm[i-1],m[i]); mxs[n]=s[n]; for(i=n-1;i>0;i--) mxs[i]=max(mxs[i-1],s[i]); for(i=1;i<n;i++) c[ a[i].second ]=max(mxm[i-1],mxs[i+1]); c[a[0].second]=mxs[1]; c[a[n].second]=mxm[n-1]; for(i=0;i<=n;i++) printf("%d ",c[i]); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:9:11: warning: unused variable 'poz' [-Wunused-variable]
 { int n,i,poz;
           ^~~
ho_t1.cpp:10:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d",&n);
 ~~~~~^~~~~~~~~
ho_t1.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&a[i].first);
     ~~~~~^~~~~~~~~~~~~~~~~~
ho_t1.cpp:17:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 for(i=0;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...