# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
466997 | 2021-08-21T08:36:10 Z | LucaIlie | Maxcomp (info1cup18_maxcomp) | C | 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
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |