#include <stdlib.h>
#include <stdio.h>
#define MAX(a,b) (a>b?a:b);
int R,C;
int a[301][301];
int dp[301][301];
sum(x,y,p,q)
{
int i,j,s=0;
for(i=x;i<=p;i++)
{
for(j=y;j<=q;j++)
{
s+=a[i][j];
}
}
return s;
}
f(x,y,s)
{
int i,j,p,q,k,t,max=0;
if(dp[x][y])return dp[x][y];
if(x==R||y==C)
{
if(x==R&&y==C)return s;
return 0;
}
for(i=x;i<R;i++)
{
for(j=y;j<C;j++)
{
k=sum(x,y,i,j);
t=f(i+1,j+1,s+k);
max=max<t?t:max;
}
}
return max;
}
main()
{
scanf("%d%d",&R,&C);
int i,j;
for(i=0;i<R;i++)
{
for(j=0;j<C;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("%d",f(0,0,0));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1796 KB |
Output is correct |
2 |
Correct |
0 ms |
1796 KB |
Output is correct |
3 |
Correct |
4 ms |
1796 KB |
Output is correct |
4 |
Execution timed out |
1000 ms |
1792 KB |
Program timed out |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |