이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(x==R||y==C)
{
if(x==R&&y==C)return s;
return 0;
}
if(dp[x][y])return dp[x][y];
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 dp[x+1][y+1]=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));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |