Submission #521319

# Submission time Handle Problem Language Result Execution time Memory
521319 2022-02-01T16:50:56 Z lucri Maxcomp (info1cup18_maxcomp) C++17
15 / 100
1 ms 332 KB
#include <iostream>
using namespace std;
long long x[1010][1010],n,m,a[1010][1010],ans=0;
int main()
{
    cin>>n>>m;
    for(long long i=1;i<=n;++i)
        for(long long j=1;j<=m;++j)
        {
            cin>>a[i][j];
            a[i][j]+=i+j;
            x[i][j]=a[i][j];
        }
    for(long long i=n;i>=1;--i)
        for(long long j=m;j>=1;--j)
        {
            if(i<n&&j<m)
                x[i][j]=min(x[i][j],min(x[i+1][j],x[i][j+1]));
            else if(i==n&&j!=m)
                x[i][j]=min(x[i][j],x[i][j+1]);
            else if(i!=n&&j==m)
                x[i][j]=min(x[i][j],x[i+1][j]);
            if(ans<a[i][j]-x[i][j]-1)
                ans=a[i][j]-x[i][j]-1;
        }
    for(long long i=n;i>=1;--i)
        for(long long j=m;j>=1;--j)
        {
            a[i][j]-=2*(i+j);
            x[i][j]=a[i][j];
            if(i<n&&j<m)
                x[i][j]=max(x[i][j],max(x[i+1][j],x[i][j+1]));
            else if(i==n&&j!=m)
                x[i][j]=max(x[i][j],x[i][j+1]);
            else if(i!=n&&j==m)
                x[i][j]=max(x[i][j],x[i+1][j]);
            if(ans<x[i][j]-a[i][j]-1)
                ans=x[i][j]-a[i][j]-1;
        }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -