Submission #413215

# Submission time Handle Problem Language Result Execution time Memory
413215 2021-05-28T11:21:08 Z aris12345678 Maxcomp (info1cup18_maxcomp) C++14
15 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 1e3+5;
int a[mxN][mxN], dp[mxN][mxN];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            dp[i][j] = a[i][j]-1;
            if(i > 0)
                dp[i][j] = max(dp[i][j], dp[i-1][j]-1);
            if(j > 0)
                dp[i][j] = max(dp[i][j], dp[i][j-1]-1);
        }
    }
    for(int i = n-1; i >= 0; i--) {
        for(int j = m-1; j >= 0; j--) {
            if(i < n-1)
                dp[i][j] = max(dp[i][j], dp[i+1][j]-1);
            if(j < m-1)
                dp[i][j] = max(dp[i][j], dp[i][j+1]-1);
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            ans = max(ans, dp[i][j]-a[i][j]);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
maxcomp.cpp:12:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |             scanf("%d", &a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -