답안 #466997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
466997 2021-08-21T08:36:10 Z LucaIlie Maxcomp (info1cup18_maxcomp) C
0 / 100
1 ms 204 KB
#include <stdio.h>

#define MAX_N 1000

struct aaa {
    int w, min, max;
};

struct aaa maxW[MAX_N][MAX_N];

int main() {
    int n, m, a, maxWeight, l, c;
    struct aaa new;

    scanf( "%d%d", &n, &m );

    maxWeight = -1;
    for ( l = 0; l < n; l++ ) {
        for ( c = 0; c < m; c++ ) {
            scanf( "%d", &a );

            maxW[l][c].min = maxW[l][c].max = a;
            maxW[l][c].w = -1;
            if ( l > 0 ) {
                new.min = maxW[l - 1][c].min < a ? maxW[l - 1][c].min : a;
                new.max = maxW[l - 1][c].max > a ? maxW[l - 1][c].max : a;
                new.w = maxW[l - 1][c].w - (maxW[l - 1][c].max - maxW[l - 1][c].min) + (new.max - new.min) - 1;
                if ( new.w > maxW[l][c].w )
                    maxW[l][c] = new;
            }
            if ( c > 0 ) {
                new.min = maxW[l][c - 1].min < a ? maxW[l][c - 1].min : a;
                new.max = maxW[l][c - 1].max > a ? maxW[l][c - 1].max : a;
                new.w = maxW[l][c - 1].w - (maxW[l][c - 1].max - maxW[l][c - 1].min) + (new.max - new.min) - 1;
                if ( new.w > maxW[l][c].w )
                    maxW[l][c] = new;
            }

            if ( maxW[l][c].w > maxWeight )
                maxWeight = maxW[l][c].w;
        }
    }

    printf( "%d", maxWeight );

    return 0;
}

Compilation message

maxcomp.c: In function 'main':
maxcomp.c:15:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf( "%d%d", &n, &m );
      |     ^~~~~~~~~~~~~~~~~~~~~~~
maxcomp.c:20:13: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |             scanf( "%d", &a );
      |             ^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -