Submission #76724

#TimeUsernameProblemLanguageResultExecution timeMemory
76724farukkastamonudaLightning Conductor (POI11_pio)C++14
100 / 100
355 ms53784 KiB
#include <bits/stdc++.h> #define li 500005 using namespace std; int n,A[li],res[li]; 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(A[i]+sqrt(abs(mid-i))>A[opt]+sqrt(abs(mid-opt))) opt=i; } res[mid]=max(res[mid],A[opt]-A[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",&A[i]); solve(1,n,1,n); reverse(A+1,A+n+1); reverse(res+1,res+n+1); solve(1,n,1,n); reverse(A+1,A+n+1); reverse(res+1,res+n+1); for(int i=1;i<=n;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:18:32: 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("%d",&A[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...