# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226373 | DodgeBallMan | Lightning Conductor (POI11_pio) | C++14 | 154 ms | 15992 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;
const int N = 5e5 + 10;
int n, mx = -1, h[N], mxl[N], mxr[N];
int main()
{
scanf("%d",&n);
for( int i = 1 ; i <= n ; i++ ) scanf("%d",&h[i]);
for( int i = 1 ; i <= n ; i++ ) {
mxl[i] = max( mxl[i], h[i] );
if( h[i] <= mx ) continue ;
mx = max( mx, h[i] );
for( int d = 0 ; i + d*d + 1 <= n ; d++ ) {
int pos = i + d*d + 1;
mxl[pos] = max( mxl[pos], h[i] + d + 1 );
}
}
mx = -1;
for( int i = n ; i >= 1 ; i-- ) {
mxr[i] = max( mxr[i], h[i] );
if( h[i] <= mx ) continue ;
mx = max( mx, h[i] );
for( int d = 0; i - d*d - 1 > 0 ; d++ ) {
int pos = i - d*d - 1;
mxr[pos] = max( mxr[pos], h[i] + d + 1 );
}
}
for( int i = 1 ; i <= n ; i++ ) mxl[i] = max( mxl[i], mxl[i-1] );
for( int i = n ; i >= 1 ; i-- ) mxr[i] = max( mxr[i], mxr[i+1] );
for( int i = 1 ; i <= n ; i++ ) printf("%d\n",max( mxl[i], mxr[i] ) - h[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... |