Submission #205312

#TimeUsernameProblemLanguageResultExecution timeMemory
205312TadijaSebezJust Long Neckties (JOI20_ho_t1)C++11
100 / 100
148 ms7036 KiB
#include <bits/stdc++.h> using namespace std; const int N=200050; int b[N],l[N],r[N]; pair<int,int> a[N]; int c[N]; int main(){ int n; scanf("%i",&n); for(int i=1;i<=n+1;i++)scanf("%i",&a[i].first),a[i].second=i; for(int i=1;i<=n;i++)scanf("%i",&b[i]); sort(a+1,a+1+n+1);sort(b+1,b+1+n); for(int i=1;i<=n;i++)l[i]=max(l[i-1],a[i].first-b[i]); for(int i=n;i>=1;i--)r[i]=max(r[i+1],a[i+1].first-b[i]); for(int i=0;i<=n;i++)c[a[i+1].second]=max(l[i],r[i+1]); for(int i=1;i<=n+1;i++)printf("%i ",c[i]);printf("\n"); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:16:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=1;i<=n+1;i++)printf("%i ",c[i]);printf("\n");
  ^~~
ho_t1.cpp:16:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=1;i<=n+1;i++)printf("%i ",c[i]);printf("\n");
                                            ^~~~~~
ho_t1.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
ho_t1.cpp:10:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n+1;i++)scanf("%i",&a[i].first),a[i].second=i;
                         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ho_t1.cpp:11:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++)scanf("%i",&b[i]);
                       ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...