Submission #45249

# Submission time Handle Problem Language Result Execution time Memory
45249 2018-04-12T07:59:23 Z ikura355 Maxcomp (info1cup18_maxcomp) C++14
15 / 100
2 ms 776 KB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e3 + 5;

int n,m;
long long p[maxn][maxn];
long long mx[maxn][maxn];

int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&p[i][j]);
    long long ans = -1;
    for(int x=1;x<=n;x++) {
        for(int y=1;y<=m;y++) {
            mx[x][y] = -p[x][y] + x + y;
            if(y!=1) mx[x][y] = max(mx[x][y], mx[x][y-1]);
            if(x!=1) mx[x][y] = max(mx[x][y], mx[x-1][y]);
            ans = max(ans, p[x][y] - x - y + mx[x][y] - 1);
        }
    }
    for(int x=n;x>=1;x--) {
        for(int y=1;y<=m;y++) {
            mx[x][y] = -p[x][y] - x + y;
            if(y!=1) mx[x][y] = max(mx[x][y], mx[x][y-1]);
            if(x!=n) mx[x][y] = max(mx[x][y], mx[x+1][y]);
            ans = max(ans, p[x][y] + x - y + mx[x][y] - 1);
        }
    }
    for(int x=1;x<=n;x++) {
        for(int y=m;y>=1;y--) {
            mx[x][y] = -p[x][y] + x - y;
            if(y!=m) mx[x][y] = max(mx[x][y], mx[x][y+1]);
            if(x!=1) mx[x][y] = max(mx[x][y], mx[x-1][y]);
            ans = max(ans, p[x][y] - x + y + mx[x][y] - 1);
        }
    }
    for(int x=n;x>=1;x--) {
        for(int y=m;y>=1;y--) {
            mx[x][y] = -p[x][y] - x - y;
            if(y!=m) mx[x][y] = max(mx[x][y], mx[x][y+1]);
            if(x!=x) mx[x][y] = max(mx[x][y], mx[x+1][y]);
            ans = max(ans, p[x][y] + x + y + mx[x][y] - 1);
        }
    }
    printf("%lld",ans);
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:12:68: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
     for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&p[i][j]);
                                                            ~~~~~~~~^
maxcomp.cpp:42:17: warning: self-comparison always evaluates to false [-Wtautological-compare]
             if(x!=x) mx[x][y] = max(mx[x][y], mx[x+1][y]);
                ~^~~
maxcomp.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
maxcomp.cpp:12:54: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&p[i][j]);
                                                 ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 664 KB Output is correct
7 Incorrect 2 ms 740 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 744 KB Output is correct
2 Correct 2 ms 752 KB Output is correct
3 Correct 2 ms 776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 664 KB Output is correct
7 Incorrect 2 ms 740 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 664 KB Output is correct
7 Incorrect 2 ms 740 KB Output isn't correct
8 Halted 0 ms 0 KB -