Submission #13555

# Submission time Handle Problem Language Result Execution time Memory
13555 2015-02-24T06:39:07 Z baneling100 On grid (kriii2_O) C++
4 / 4
64 ms 1792 KB
#include <stdio.h>
#include <algorithm>
#define R_MAX 300
#define C_MAX 300
#define INF 1000000000

using namespace std;

int R, C, G[R_MAX+1][C_MAX+1], D[R_MAX+1][C_MAX+1], K[R_MAX+1];

int main(void) {

    int i, j, k, sum;

    scanf("%d %d",&R,&C);
    for(i=1 ; i<=R ; i++) for(j=1 ; j<=C ; j++) {
        scanf("%d",&G[i][j]);
        D[i][j]=-INF;
    }
    for(i=1 ; i<=R ; i++) D[i][0]=-INF;
    for(i=1 ; i<=C ; i++) D[0][i]=-INF;
    for(i=1 ; i<=R ; i++) {
        for(j=1 ; j<=i ; j++) K[j]=-INF;
        for(j=1 ; j<=C ; j++) {
            sum=0;
            for(k=i ; k>=1 ; k--) {
                sum+=G[k][j];
                K[k]=max(K[k],D[k-1][j-1])+sum;
                D[i][j]=max(D[i][j],K[k]);
            }
        }
    }
    printf("%d",D[R][C]);

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1792 KB Output is correct
2 Correct 0 ms 1792 KB Output is correct
3 Correct 0 ms 1792 KB Output is correct
4 Correct 0 ms 1792 KB Output is correct
5 Correct 0 ms 1792 KB Output is correct
6 Correct 0 ms 1792 KB Output is correct
7 Correct 0 ms 1792 KB Output is correct
8 Correct 0 ms 1792 KB Output is correct
9 Correct 0 ms 1792 KB Output is correct
10 Correct 0 ms 1792 KB Output is correct
11 Correct 0 ms 1792 KB Output is correct
12 Correct 0 ms 1792 KB Output is correct
13 Correct 0 ms 1792 KB Output is correct
14 Correct 0 ms 1792 KB Output is correct
15 Correct 0 ms 1792 KB Output is correct
16 Correct 0 ms 1792 KB Output is correct
17 Correct 0 ms 1792 KB Output is correct
18 Correct 0 ms 1792 KB Output is correct
19 Correct 0 ms 1792 KB Output is correct
20 Correct 0 ms 1792 KB Output is correct
21 Correct 0 ms 1792 KB Output is correct
22 Correct 0 ms 1792 KB Output is correct
23 Correct 0 ms 1792 KB Output is correct
24 Correct 0 ms 1792 KB Output is correct
25 Correct 0 ms 1792 KB Output is correct
26 Correct 0 ms 1792 KB Output is correct
27 Correct 0 ms 1792 KB Output is correct
28 Correct 0 ms 1792 KB Output is correct
29 Correct 0 ms 1792 KB Output is correct
30 Correct 0 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1792 KB Output is correct
2 Correct 9 ms 1792 KB Output is correct
3 Correct 23 ms 1792 KB Output is correct
4 Correct 17 ms 1792 KB Output is correct
5 Correct 7 ms 1792 KB Output is correct
6 Correct 26 ms 1792 KB Output is correct
7 Correct 13 ms 1792 KB Output is correct
8 Correct 36 ms 1792 KB Output is correct
9 Correct 60 ms 1792 KB Output is correct
10 Correct 57 ms 1792 KB Output is correct
11 Correct 14 ms 1792 KB Output is correct
12 Correct 17 ms 1792 KB Output is correct
13 Correct 10 ms 1792 KB Output is correct
14 Correct 53 ms 1792 KB Output is correct
15 Correct 18 ms 1792 KB Output is correct
16 Correct 8 ms 1792 KB Output is correct
17 Correct 27 ms 1792 KB Output is correct
18 Correct 26 ms 1792 KB Output is correct
19 Correct 25 ms 1792 KB Output is correct
20 Correct 9 ms 1792 KB Output is correct
21 Correct 11 ms 1792 KB Output is correct
22 Correct 8 ms 1792 KB Output is correct
23 Correct 8 ms 1792 KB Output is correct
24 Correct 50 ms 1792 KB Output is correct
25 Correct 8 ms 1792 KB Output is correct
26 Correct 7 ms 1792 KB Output is correct
27 Correct 51 ms 1792 KB Output is correct
28 Correct 18 ms 1792 KB Output is correct
29 Correct 7 ms 1792 KB Output is correct
30 Correct 9 ms 1792 KB Output is correct
31 Correct 20 ms 1792 KB Output is correct
32 Correct 62 ms 1792 KB Output is correct
33 Correct 24 ms 1792 KB Output is correct
34 Correct 7 ms 1792 KB Output is correct
35 Correct 9 ms 1792 KB Output is correct
36 Correct 64 ms 1792 KB Output is correct
37 Correct 9 ms 1792 KB Output is correct
38 Correct 7 ms 1792 KB Output is correct
39 Correct 10 ms 1792 KB Output is correct
40 Correct 6 ms 1792 KB Output is correct