Submission #9665

# Submission time Handle Problem Language Result Execution time Memory
9665 2014-09-28T07:58:44 Z yukariko On grid (kriii2_O) C
0 / 4
0 ms 1796 KB
#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]>s*2)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][y]=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
1 Correct 0 ms 1796 KB Output is correct
2 Correct 0 ms 1796 KB Output is correct
3 Incorrect 0 ms 1796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -