# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
466997 | LucaIlie | Maxcomp (info1cup18_maxcomp) | C11 | 1 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |