Submission #8843

# Submission time Handle Problem Language Result Execution time Memory
8843 2014-09-21T10:51:29 Z gs13068 On grid (kriii2_O) C++
4 / 4
104 ms 108320 KB
#include<cstdio>
#include<algorithm>

int a[301][301];
int t[301][301];
int d[301][301][301];

int main()
{
	int i,j,k,l,n,m;
	scanf("%d%d",&n,&m);
    for(i=0;i<=n;i++)for(j=0;j<=m;j++)
    {
    	t[i][j]=-1e9;
    	for(k=0;k<=m;k++)d[i][j][k]=-1e9;
    }
	t[0][0]=0;
    d[0][0][0]=0;
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)
	{
		scanf("%d",&a[i][j]);
        a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
        t[i][j]=-1e9;
        for(k=0;k<j;k++)
		{
			d[i][j][k]=std::max(d[i-1][j][k],t[i-1][k])+a[i][j]-a[i-1][j]-a[i][k]+a[i-1][k];
			t[i][j]=std::max(t[i][j],d[i][j][k]);
		}
	}
	printf("%d",t[n][m]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 108320 KB Output is correct
2 Correct 0 ms 108320 KB Output is correct
3 Correct 0 ms 108320 KB Output is correct
4 Correct 0 ms 108320 KB Output is correct
5 Correct 0 ms 108320 KB Output is correct
6 Correct 0 ms 108320 KB Output is correct
7 Correct 0 ms 108320 KB Output is correct
8 Correct 0 ms 108320 KB Output is correct
9 Correct 0 ms 108320 KB Output is correct
10 Correct 0 ms 108320 KB Output is correct
11 Correct 0 ms 108320 KB Output is correct
12 Correct 0 ms 108320 KB Output is correct
13 Correct 0 ms 108320 KB Output is correct
14 Correct 0 ms 108320 KB Output is correct
15 Correct 0 ms 108320 KB Output is correct
16 Correct 0 ms 108320 KB Output is correct
17 Correct 0 ms 108320 KB Output is correct
18 Correct 0 ms 108320 KB Output is correct
19 Correct 0 ms 108320 KB Output is correct
20 Correct 0 ms 108320 KB Output is correct
21 Correct 0 ms 108320 KB Output is correct
22 Correct 0 ms 108320 KB Output is correct
23 Correct 0 ms 108320 KB Output is correct
24 Correct 0 ms 108320 KB Output is correct
25 Correct 0 ms 108320 KB Output is correct
26 Correct 0 ms 108320 KB Output is correct
27 Correct 0 ms 108320 KB Output is correct
28 Correct 0 ms 108320 KB Output is correct
29 Correct 0 ms 108320 KB Output is correct
30 Correct 0 ms 108320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 108320 KB Output is correct
2 Correct 12 ms 108320 KB Output is correct
3 Correct 24 ms 108320 KB Output is correct
4 Correct 8 ms 108320 KB Output is correct
5 Correct 12 ms 108320 KB Output is correct
6 Correct 60 ms 108320 KB Output is correct
7 Correct 28 ms 108320 KB Output is correct
8 Correct 48 ms 108320 KB Output is correct
9 Correct 84 ms 108320 KB Output is correct
10 Correct 84 ms 108320 KB Output is correct
11 Correct 44 ms 108320 KB Output is correct
12 Correct 16 ms 108320 KB Output is correct
13 Correct 12 ms 108320 KB Output is correct
14 Correct 48 ms 108320 KB Output is correct
15 Correct 16 ms 108320 KB Output is correct
16 Correct 8 ms 108320 KB Output is correct
17 Correct 56 ms 108320 KB Output is correct
18 Correct 44 ms 108320 KB Output is correct
19 Correct 16 ms 108320 KB Output is correct
20 Correct 20 ms 108320 KB Output is correct
21 Correct 16 ms 108320 KB Output is correct
22 Correct 16 ms 108320 KB Output is correct
23 Correct 12 ms 108320 KB Output is correct
24 Correct 60 ms 108320 KB Output is correct
25 Correct 20 ms 108320 KB Output is correct
26 Correct 8 ms 108320 KB Output is correct
27 Correct 48 ms 108320 KB Output is correct
28 Correct 32 ms 108320 KB Output is correct
29 Correct 20 ms 108320 KB Output is correct
30 Correct 36 ms 108320 KB Output is correct
31 Correct 32 ms 108320 KB Output is correct
32 Correct 68 ms 108320 KB Output is correct
33 Correct 40 ms 108320 KB Output is correct
34 Correct 20 ms 108320 KB Output is correct
35 Correct 12 ms 108320 KB Output is correct
36 Correct 104 ms 108320 KB Output is correct
37 Correct 28 ms 108320 KB Output is correct
38 Correct 32 ms 108320 KB Output is correct
39 Correct 16 ms 108320 KB Output is correct
40 Correct 12 ms 108320 KB Output is correct