답안 #8380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
8380 2014-09-13T16:03:53 Z ainta On grid (kriii2_O) C++
4 / 4
64 ms 2216 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
int D[2][310][310], n, m, S[310][310], pv, D2[2][310];
int main()
{
	int i, j, k;
	scanf("%d%d", &n,&m);
	for (i = 1; i <= n; i++){
		for (j = 1; j <= m; j++){
			scanf("%d", &S[i][j]);
			S[i][j] += S[i][j - 1];
		}
	}
	for (i = 1; i <= m; i++){
		D2[0][i] = D[0][i][i] = S[1][i];
		for (j = 1; j < i; j++)D[0][i][j] = -1999999999;
	}
	for (i = 2; i <= n; i++){
		for (j = 1; j <= m; j++)D2[!pv][j] = -1999999999;
		D2[pv][0] = -1999999999;
		for (j = 1; j <= m; j++){
			for (k = 1; k <= j; k++){
				D[!pv][j][k] = max(D[pv][j][k], D2[pv][j - k]) + S[i][j] - S[i][j - k];
				D2[!pv][j] = max(D2[!pv][j], D[!pv][j][k]);
			}
		}
		pv = !pv;
	}
	printf("%d\n", D2[pv][m]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Correct 0 ms 2216 KB Output is correct
4 Correct 0 ms 2216 KB Output is correct
5 Correct 0 ms 2216 KB Output is correct
6 Correct 0 ms 2216 KB Output is correct
7 Correct 0 ms 2216 KB Output is correct
8 Correct 0 ms 2216 KB Output is correct
9 Correct 0 ms 2216 KB Output is correct
10 Correct 0 ms 2216 KB Output is correct
11 Correct 0 ms 2216 KB Output is correct
12 Correct 0 ms 2216 KB Output is correct
13 Correct 0 ms 2216 KB Output is correct
14 Correct 0 ms 2216 KB Output is correct
15 Correct 0 ms 2216 KB Output is correct
16 Correct 0 ms 2216 KB Output is correct
17 Correct 0 ms 2216 KB Output is correct
18 Correct 0 ms 2216 KB Output is correct
19 Correct 0 ms 2216 KB Output is correct
20 Correct 0 ms 2216 KB Output is correct
21 Correct 0 ms 2216 KB Output is correct
22 Correct 0 ms 2216 KB Output is correct
23 Correct 0 ms 2216 KB Output is correct
24 Correct 0 ms 2216 KB Output is correct
25 Correct 0 ms 2216 KB Output is correct
26 Correct 0 ms 2216 KB Output is correct
27 Correct 0 ms 2216 KB Output is correct
28 Correct 0 ms 2216 KB Output is correct
29 Correct 0 ms 2216 KB Output is correct
30 Correct 0 ms 2216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2216 KB Output is correct
2 Correct 4 ms 2216 KB Output is correct
3 Correct 12 ms 2216 KB Output is correct
4 Correct 8 ms 2216 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 36 ms 2216 KB Output is correct
7 Correct 12 ms 2216 KB Output is correct
8 Correct 40 ms 2216 KB Output is correct
9 Correct 52 ms 2216 KB Output is correct
10 Correct 64 ms 2216 KB Output is correct
11 Correct 20 ms 2216 KB Output is correct
12 Correct 12 ms 2216 KB Output is correct
13 Correct 8 ms 2216 KB Output is correct
14 Correct 44 ms 2216 KB Output is correct
15 Correct 16 ms 2216 KB Output is correct
16 Correct 4 ms 2216 KB Output is correct
17 Correct 32 ms 2216 KB Output is correct
18 Correct 28 ms 2216 KB Output is correct
19 Correct 8 ms 2216 KB Output is correct
20 Correct 12 ms 2216 KB Output is correct
21 Correct 12 ms 2216 KB Output is correct
22 Correct 4 ms 2216 KB Output is correct
23 Correct 8 ms 2216 KB Output is correct
24 Correct 44 ms 2216 KB Output is correct
25 Correct 12 ms 2216 KB Output is correct
26 Correct 4 ms 2216 KB Output is correct
27 Correct 44 ms 2216 KB Output is correct
28 Correct 20 ms 2216 KB Output is correct
29 Correct 16 ms 2216 KB Output is correct
30 Correct 20 ms 2216 KB Output is correct
31 Correct 28 ms 2216 KB Output is correct
32 Correct 52 ms 2216 KB Output is correct
33 Correct 32 ms 2216 KB Output is correct
34 Correct 12 ms 2216 KB Output is correct
35 Correct 4 ms 2216 KB Output is correct
36 Correct 64 ms 2216 KB Output is correct
37 Correct 16 ms 2216 KB Output is correct
38 Correct 20 ms 2216 KB Output is correct
39 Correct 8 ms 2216 KB Output is correct
40 Correct 8 ms 2216 KB Output is correct