# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85637 | memetkagan44 | Lightning Conductor (POI11_pio) | C++11 | 334 ms | 33232 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |