Submission #85637

#TimeUsernameProblemLanguageResultExecution timeMemory
85637memetkagan44Lightning Conductor (POI11_pio)C++11
100 / 100
334 ms33232 KiB
#include<bits/stdc++.h> using namespace std; int n,ar[500005],res[500005]; void solve(int l,int r,int optl,int optr){ if(l>r) return; int mid=(l+r)/2; int opt=optl; for(int i=optl;i<=min(optr,mid);i++) if(ar[i]+sqrt(abs(mid-i))>ar[opt]+sqrt(abs(mid-opt))) opt=i; res[mid]=max(res[mid],ar[opt]-ar[mid]+(int)ceil(sqrt(abs(mid-opt)))); solve(l,mid-1,optl,opt); solve(mid+1,r,opt,optr); } int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&ar[i]); solve(1,n,1,n); reverse(ar+1,ar+n+1); reverse(res+1,res+n+1); solve(1,n,1,n); for(int i=n;i>=1;i--) printf("%d\n",res[i]); return 0; }

Compilation message (stderr)

pio.cpp: In function 'int main()':
pio.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
pio.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&ar[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...