답안 #10114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
10114 2014-10-15T09:57:15 Z gs14004 On grid (kriii2_O) C++
4 / 4
68 ms 2504 KB
#include <cstdio>
#include <algorithm>
#include <deque>
using namespace std;

int a[301][301];
int sum[301][301];
int dp[301][301];
int r,c;

int mem[301][301];

void prep(){
    scanf("%d %d",&r,&c);
    for (int i=1; i<=r; i++) {
        for (int j=1; j<=c; j++) {
            scanf("%d",&a[i][j]);
        }
    }
    for (int i=1; i<=r; i++) {
        for (int j=1; j<=c; j++) {
            sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + a[i][j];
        }
    }
}

int main(){
    prep();
    for (int j=1; j<=c; j++) {
        for (int i=1; i<=r; i++) {
            if(j != 1)for (int k=1; k<i; k++) {
                dp[i][j] = max(dp[i][j], mem[k][i] - sum[k][j]);
            }
            dp[i][j] += 2*sum[i][j];
        }
        for (int i=1; i<=r; i++) {
            for (int k=i+1; k<=r; k++) {
                if(j == 1) mem[i][k] = dp[i][j] - sum[k][j];
                mem[i][k] = max(mem[i][k],dp[i][j] - sum[k][j]);
            }
        }
    }
    printf("%d",dp[r][c]-sum[r][c]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2504 KB Output is correct
2 Correct 0 ms 2504 KB Output is correct
3 Correct 0 ms 2504 KB Output is correct
4 Correct 0 ms 2504 KB Output is correct
5 Correct 0 ms 2504 KB Output is correct
6 Correct 0 ms 2504 KB Output is correct
7 Correct 0 ms 2504 KB Output is correct
8 Correct 0 ms 2504 KB Output is correct
9 Correct 0 ms 2504 KB Output is correct
10 Correct 0 ms 2504 KB Output is correct
11 Correct 0 ms 2504 KB Output is correct
12 Correct 0 ms 2504 KB Output is correct
13 Correct 0 ms 2504 KB Output is correct
14 Correct 0 ms 2504 KB Output is correct
15 Correct 0 ms 2504 KB Output is correct
16 Correct 0 ms 2504 KB Output is correct
17 Correct 0 ms 2504 KB Output is correct
18 Correct 0 ms 2504 KB Output is correct
19 Correct 0 ms 2504 KB Output is correct
20 Correct 0 ms 2504 KB Output is correct
21 Correct 0 ms 2504 KB Output is correct
22 Correct 0 ms 2504 KB Output is correct
23 Correct 0 ms 2504 KB Output is correct
24 Correct 0 ms 2504 KB Output is correct
25 Correct 0 ms 2504 KB Output is correct
26 Correct 0 ms 2504 KB Output is correct
27 Correct 0 ms 2504 KB Output is correct
28 Correct 0 ms 2504 KB Output is correct
29 Correct 0 ms 2504 KB Output is correct
30 Correct 0 ms 2504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2504 KB Output is correct
2 Correct 8 ms 2504 KB Output is correct
3 Correct 28 ms 2504 KB Output is correct
4 Correct 16 ms 2504 KB Output is correct
5 Correct 0 ms 2504 KB Output is correct
6 Correct 16 ms 2504 KB Output is correct
7 Correct 12 ms 2504 KB Output is correct
8 Correct 32 ms 2504 KB Output is correct
9 Correct 56 ms 2504 KB Output is correct
10 Correct 64 ms 2504 KB Output is correct
11 Correct 16 ms 2504 KB Output is correct
12 Correct 20 ms 2504 KB Output is correct
13 Correct 8 ms 2504 KB Output is correct
14 Correct 52 ms 2504 KB Output is correct
15 Correct 16 ms 2504 KB Output is correct
16 Correct 8 ms 2504 KB Output is correct
17 Correct 28 ms 2504 KB Output is correct
18 Correct 24 ms 2504 KB Output is correct
19 Correct 16 ms 2504 KB Output is correct
20 Correct 8 ms 2504 KB Output is correct
21 Correct 8 ms 2504 KB Output is correct
22 Correct 8 ms 2504 KB Output is correct
23 Correct 12 ms 2504 KB Output is correct
24 Correct 56 ms 2504 KB Output is correct
25 Correct 8 ms 2504 KB Output is correct
26 Correct 4 ms 2504 KB Output is correct
27 Correct 48 ms 2504 KB Output is correct
28 Correct 20 ms 2504 KB Output is correct
29 Correct 12 ms 2504 KB Output is correct
30 Correct 8 ms 2504 KB Output is correct
31 Correct 16 ms 2504 KB Output is correct
32 Correct 52 ms 2504 KB Output is correct
33 Correct 28 ms 2504 KB Output is correct
34 Correct 8 ms 2504 KB Output is correct
35 Correct 12 ms 2504 KB Output is correct
36 Correct 68 ms 2504 KB Output is correct
37 Correct 12 ms 2504 KB Output is correct
38 Correct 12 ms 2504 KB Output is correct
39 Correct 12 ms 2504 KB Output is correct
40 Correct 4 ms 2504 KB Output is correct