답안 #16512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16512 2015-08-27T00:25:16 Z hongjun7 On grid (kriii2_O) C++
4 / 4
79 ms 2172 KB
#include <stdio.h>
#define MN 305
#define max(a, b) ((a)>(b)?(a):(b))
const int oo = 1e9;
int n, m, x, c[MN][MN], d[MN][MN], f[MN][MN];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf("%d", &x);
			c[i][j] = x + c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1];
		}
	}
	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) f[i][j] = -oo;
	for (int j = 1; j <= m; j++) {
		for (int i = n; i >= 1; i--) {
			d[i][j] = c[i][j];
			for (int k = 0; k < i; k++) d[i][j] = max(d[i][j], f[k][i] + c[i][j] - c[k][j]);
			for (int k = i + 1; k <= n; k++) f[i][k] = max(f[i][k], d[i][j] - c[k][j] + c[i][j]);
		}
	}
	printf("%d", d[n][m]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
4 Correct 0 ms 2172 KB Output is correct
5 Correct 0 ms 2172 KB Output is correct
6 Correct 0 ms 2172 KB Output is correct
7 Correct 0 ms 2172 KB Output is correct
8 Correct 0 ms 2172 KB Output is correct
9 Correct 0 ms 2172 KB Output is correct
10 Correct 0 ms 2172 KB Output is correct
11 Correct 0 ms 2172 KB Output is correct
12 Correct 0 ms 2172 KB Output is correct
13 Correct 0 ms 2172 KB Output is correct
14 Correct 0 ms 2172 KB Output is correct
15 Correct 0 ms 2172 KB Output is correct
16 Correct 0 ms 2172 KB Output is correct
17 Correct 0 ms 2172 KB Output is correct
18 Correct 0 ms 2172 KB Output is correct
19 Correct 0 ms 2172 KB Output is correct
20 Correct 0 ms 2172 KB Output is correct
21 Correct 0 ms 2172 KB Output is correct
22 Correct 0 ms 2172 KB Output is correct
23 Correct 0 ms 2172 KB Output is correct
24 Correct 0 ms 2172 KB Output is correct
25 Correct 0 ms 2172 KB Output is correct
26 Correct 0 ms 2172 KB Output is correct
27 Correct 0 ms 2172 KB Output is correct
28 Correct 0 ms 2172 KB Output is correct
29 Correct 0 ms 2172 KB Output is correct
30 Correct 0 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2172 KB Output is correct
2 Correct 5 ms 2172 KB Output is correct
3 Correct 27 ms 2172 KB Output is correct
4 Correct 20 ms 2172 KB Output is correct
5 Correct 4 ms 2172 KB Output is correct
6 Correct 29 ms 2172 KB Output is correct
7 Correct 11 ms 2172 KB Output is correct
8 Correct 37 ms 2172 KB Output is correct
9 Correct 72 ms 2172 KB Output is correct
10 Correct 75 ms 2172 KB Output is correct
11 Correct 20 ms 2172 KB Output is correct
12 Correct 21 ms 2172 KB Output is correct
13 Correct 12 ms 2172 KB Output is correct
14 Correct 59 ms 2172 KB Output is correct
15 Correct 19 ms 2172 KB Output is correct
16 Correct 12 ms 2172 KB Output is correct
17 Correct 34 ms 2172 KB Output is correct
18 Correct 31 ms 2172 KB Output is correct
19 Correct 27 ms 2172 KB Output is correct
20 Correct 9 ms 2172 KB Output is correct
21 Correct 11 ms 2172 KB Output is correct
22 Correct 8 ms 2172 KB Output is correct
23 Correct 9 ms 2172 KB Output is correct
24 Correct 60 ms 2172 KB Output is correct
25 Correct 9 ms 2172 KB Output is correct
26 Correct 4 ms 2172 KB Output is correct
27 Correct 56 ms 2172 KB Output is correct
28 Correct 23 ms 2172 KB Output is correct
29 Correct 14 ms 2172 KB Output is correct
30 Correct 15 ms 2172 KB Output is correct
31 Correct 24 ms 2172 KB Output is correct
32 Correct 73 ms 2172 KB Output is correct
33 Correct 37 ms 2172 KB Output is correct
34 Correct 13 ms 2172 KB Output is correct
35 Correct 13 ms 2172 KB Output is correct
36 Correct 79 ms 2172 KB Output is correct
37 Correct 15 ms 2172 KB Output is correct
38 Correct 13 ms 2172 KB Output is correct
39 Correct 12 ms 2172 KB Output is correct
40 Correct 12 ms 2172 KB Output is correct