Submission #521328

# Submission time Handle Problem Language Result Execution time Memory
521328 2022-02-01T17:16:43 Z lucri Maxcomp (info1cup18_maxcomp) C++17
100 / 100
394 ms 24664 KB
#include <iostream>
using namespace std;
long long x[1010][1010],n,m,a[1010][1010],ans=-100000000000;
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(j<m)
                x[i][j]=min(x[i][j],x[i][j+1]);
            if(i<n)
                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(j<m)
                x[i][j]=max(x[i][j],x[i][j+1]);
            if(i<n)
                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;
        }
    for(long long i=1;i<=n;++i)
        for(long long j=m;j>=1;--j)
        {
            a[i][j]+=2*i;
            x[i][j]=a[i][j];
            if(j<m)
                x[i][j]=max(x[i][j],x[i][j+1]);
            if(i>1)
                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;
        }
    for(long long i=1;i<=n;++i)
        for(long long j=m;j>=1;--j)
        {
            a[i][j]+=2*j-2*i;
            x[i][j]=a[i][j];
            if(j<m)
                x[i][j]=min(x[i][j],x[i][j+1]);
            if(i>1)
                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;
        }
    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 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
# 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 308 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 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 712 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 2 ms 692 KB Output is correct
13 Correct 2 ms 716 KB Output is correct
14 Correct 1 ms 716 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 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 712 KB Output is correct
13 Correct 2 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 716 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 361 ms 24632 KB Output is correct
19 Correct 342 ms 24616 KB Output is correct
20 Correct 336 ms 24264 KB Output is correct
21 Correct 351 ms 24516 KB Output is correct
22 Correct 345 ms 24616 KB Output is correct
23 Correct 394 ms 24664 KB Output is correct
24 Correct 358 ms 24608 KB Output is correct