답안 #10100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
10100 2014-10-15T05:37:04 Z gs14004 On grid (kriii2_O) C++
1 / 4
1000 ms 2148 KB
#include <cstdio>
#include <algorithm>
using namespace std;

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

int recsum(int x1, int x2, int y1, int y2){
    return sum[x2][y2] - sum[x1-1][y2] - sum[x2][y1-1] + sum[x1-1][y1-1];
}
int f(int x, int y){
    if(dp[x][y]) return dp[x][y];
    int res = recsum(1,x,1,y);
    for (int i=2; i<=x; i++) {
        for (int j=2; j<=y; j++) {
            res = max(res,f(i-1,j-1) + recsum(i,x,j,y));
        }
    }
    return dp[x][y] = res;
}
int main(){
    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];
        }
    }
    printf("%d",f(r,c));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2148 KB Output is correct
2 Correct 0 ms 2148 KB Output is correct
3 Correct 0 ms 2148 KB Output is correct
4 Correct 0 ms 2148 KB Output is correct
5 Correct 0 ms 2148 KB Output is correct
6 Correct 0 ms 2148 KB Output is correct
7 Correct 0 ms 2148 KB Output is correct
8 Correct 0 ms 2148 KB Output is correct
9 Correct 0 ms 2148 KB Output is correct
10 Correct 0 ms 2148 KB Output is correct
11 Correct 0 ms 2148 KB Output is correct
12 Correct 0 ms 2148 KB Output is correct
13 Correct 0 ms 2148 KB Output is correct
14 Correct 0 ms 2148 KB Output is correct
15 Correct 0 ms 2148 KB Output is correct
16 Correct 0 ms 2148 KB Output is correct
17 Correct 0 ms 2148 KB Output is correct
18 Correct 0 ms 2148 KB Output is correct
19 Correct 0 ms 2148 KB Output is correct
20 Correct 0 ms 2148 KB Output is correct
21 Correct 0 ms 2148 KB Output is correct
22 Correct 0 ms 2148 KB Output is correct
23 Correct 0 ms 2148 KB Output is correct
24 Correct 0 ms 2148 KB Output is correct
25 Correct 0 ms 2148 KB Output is correct
26 Correct 0 ms 2148 KB Output is correct
27 Correct 0 ms 2148 KB Output is correct
28 Correct 0 ms 2148 KB Output is correct
29 Correct 0 ms 2148 KB Output is correct
30 Correct 0 ms 2148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 2148 KB Program timed out
2 Halted 0 ms 0 KB -