Submission #45424

# Submission time Handle Problem Language Result Execution time Memory
45424 2018-04-13T09:30:53 Z choikiwon Maxcomp (info1cup18_maxcomp) C++17
60 / 100
199 ms 4632 KB
#include<bits/stdc++.h>
using namespace std;

int N, M;
int A[1010][1010];
int mn1[1010], mn2[1010];

int main() {
    scanf("%d %d", &N, &M);

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            scanf("%d", &A[i][j]);
        }
    }

    int ans = -2e9;

    for(int i = 0; i < M; i++) {
        mn1[i] = 2e9;
        mn2[i] = 2e9;
    }

    for(int i = N - 1; i >= 0; i--) {
        int tmn1 = 2e9;
        int tmn2 = 2e9;
        for(int j = 0; j < M; j++) {
            ans = max(ans, A[i][j] + i - j - tmn1 - 1);
            mn1[j] = min(mn1[j], A[i][j] + i - j);
            tmn1 = min(tmn1, mn1[j]);
        }
        for(int j = M - 1; j >= 0; j--) {
            ans = max(ans, A[i][j] + i + j - tmn2 - 1);
            mn2[j] = min(mn2[j], A[i][j] + i + j);
            tmn2 = min(tmn2, mn2[j]);
        }
    }

    for(int i = 0; i < M; i++) {
        mn1[i] = 2e9;
        mn2[i] = 2e9;
    }

    for(int i = 0; i < N; i++) {
        int tmn1 = 2e9;
        int tmn2 = 2e9;
        for(int j = M - 1; j >= 0; j--) {
            ans = max(ans, A[i][j] - (i - j) - tmn1 - 1);
            mn1[j] = min(mn1[j], A[i][j] - (i - j));
            tmn1 = min(tmn1, mn1[j]);
        }
        for(int j = 0; j < M; j++) {
            ans = max(ans, A[i][j] - (i + j) - tmn2 - 1);
            mn2[j] = min(mn2[j], A[i][j] - (i + j));
            tmn2 = min(tmn2, mn2[j]);
        }
    }

    printf("%d", ans);
}

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]
     scanf("%d %d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~~
maxcomp.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &A[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 556 KB Output is correct
4 Correct 2 ms 688 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 2 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 688 KB Output is correct
2 Correct 2 ms 688 KB Output is correct
3 Correct 2 ms 688 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 556 KB Output is correct
4 Correct 2 ms 688 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 2 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 2 ms 764 KB Output is correct
12 Correct 3 ms 764 KB Output is correct
13 Correct 2 ms 764 KB Output is correct
14 Correct 2 ms 764 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 556 KB Output is correct
4 Correct 2 ms 688 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 2 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 688 KB Output is correct
12 Correct 2 ms 764 KB Output is correct
13 Correct 2 ms 764 KB Output is correct
14 Correct 2 ms 764 KB Output is correct
15 Correct 3 ms 764 KB Output is correct
16 Correct 2 ms 764 KB Output is correct
17 Correct 2 ms 764 KB Output is correct
18 Correct 181 ms 4552 KB Output is correct
19 Correct 199 ms 4604 KB Output is correct
20 Correct 171 ms 4608 KB Output is correct
21 Correct 185 ms 4632 KB Output is correct
22 Correct 193 ms 4632 KB Output is correct
23 Correct 190 ms 4632 KB Output is correct
24 Incorrect 152 ms 4632 KB Output isn't correct