Submission #169324

# Submission time Handle Problem Language Result Execution time Memory
169324 2019-12-19T18:20:47 Z Rouge_Hugo Maxcomp (info1cup18_maxcomp) C++14
15 / 100
9 ms 8356 KB
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;

int n,m;
const ll inf=1e11+10;
ll a[1009][1009];
ll b[1009][1009];
int main()
{
    fast;
    cin>>n>>m;
    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<m+1;j++)
        {
            cin>>a[i][j];
        }
    }
    ll re=0;
    for(int i=1;i<n+1;i++)
    {
        ll mx=0;
        for(int j=1;j<m+1;j++)
        {
            b[i][j]=max(b[i-1][j]-1,a[i][j]);
        }
        for(int j=1;j<m+1;j++)
        {
            mx=max(mx,b[i][j]);
            re=max(re,mx-a[i][j]-1);
            mx--;
        }
        mx=0;
        for(int j=m;j>0;j--)
        {
            mx=max(mx,b[i][j]);
            re=max(re,mx-a[i][j]-1);
            mx--;
        }
    }
    memset(b,0,sizeof b);
    for(int j=1;j<m+1;j++)
        b[0][j]=inf;
    for(int i=1;i<n+1;i++)
    {
        ll mx=inf;
        for(int j=1;j<m+1;j++)
        {
            b[i][j]=min(b[i-1][j]+1,a[i][j]);
        }
        for(int j=1;j<m+1;j++)
        {
            mx=min(mx,b[i][j]);
            re=max(re,a[i][j]-1-mx);
            mx++;
        }
        mx=inf;
        for(int j=m;j>0;j--)
        {
            mx=min(mx,b[i][j]);
            re=max(re,a[i][j]-1-mx);
            mx++;
        }
    }
    cout<<re;

}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 8 ms 8312 KB Output is correct
3 Incorrect 8 ms 8312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8312 KB Output is correct
2 Correct 9 ms 8356 KB Output is correct
3 Correct 9 ms 8312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 8 ms 8312 KB Output is correct
3 Incorrect 8 ms 8312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 8 ms 8312 KB Output is correct
3 Incorrect 8 ms 8312 KB Output isn't correct
4 Halted 0 ms 0 KB -