Submission #85637

# Submission time Handle Problem Language Result Execution time Memory
85637 2018-11-21T08:26:07 Z memetkagan44 Lightning Conductor (POI11_pio) C++11
100 / 100
334 ms 33232 KB
#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

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 time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2808 KB Output is correct
2 Correct 33 ms 2808 KB Output is correct
3 Correct 41 ms 3424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 4612 KB Output is correct
2 Correct 66 ms 5576 KB Output is correct
3 Correct 57 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 10028 KB Output is correct
2 Correct 133 ms 11832 KB Output is correct
3 Correct 135 ms 13856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 288 ms 20056 KB Output is correct
2 Correct 220 ms 21504 KB Output is correct
3 Correct 216 ms 25624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 331 ms 32924 KB Output is correct
2 Correct 307 ms 32924 KB Output is correct
3 Correct 334 ms 33144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 33144 KB Output is correct
2 Correct 312 ms 33144 KB Output is correct
3 Correct 314 ms 33232 KB Output is correct