Submission #202992

# Submission time Handle Problem Language Result Execution time Memory
202992 2020-02-18T22:21:59 Z MKopchev Lightning Conductor (POI11_pio) C++14
81 / 100
1000 ms 11336 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=5e5+42;
int n,inp[nmax];

int mx_left[nmax],mx_right[nmax];

int main()
{
    scanf("%i",&n);
    for(int i=1;i<=n;i++)scanf("%i",&inp[i]);

    for(int i=1;i<=n;i++)
    {
        mx_left[i]=max(mx_left[i],inp[i]);
        mx_right[i]=max(mx_right[i],inp[i]);

        for(int d=0;i+d*d+1<=n;d++)
        {
            int j=i+d*d+1;
            mx_left[j]=max(mx_left[j],inp[i]+d+1);
        }
        for(int d=0;i-d*d-1>=1;d++)
        {
            int j=i-d*d-1;
            mx_right[j]=max(mx_right[j],inp[i]+d+1);
        }
    }

    for(int i=1;i<=n;i++)
        mx_left[i]=max(mx_left[i],mx_left[i-1]);
    for(int i=n;i>=1;i--)
        mx_right[i]=max(mx_right[i],mx_right[i+1]);

    for(int i=1;i<=n;i++)
        printf("%i\n",max(mx_left[i],mx_right[i])-inp[i]);

    return 0;
}

Compilation message

pio.cpp: In function 'int main()':
pio.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
pio.cpp:11:31: 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("%i",&inp[i]);
                          ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 2168 KB Output is correct
2 Correct 62 ms 1528 KB Output is correct
3 Correct 66 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 3056 KB Output is correct
2 Correct 109 ms 2808 KB Output is correct
3 Correct 111 ms 3068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 377 ms 6672 KB Output is correct
2 Correct 391 ms 6124 KB Output is correct
3 Correct 371 ms 6008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 734 ms 11336 KB Output is correct
2 Correct 697 ms 9348 KB Output is correct
3 Correct 708 ms 9976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1012 ms 10848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1002 ms 10876 KB Time limit exceeded
2 Halted 0 ms 0 KB -