1 #include<cstdio>
 2 #include<algorithm>
 3 #define MAXN 2010
 4 using namespace std;
 5 int a[MAXN][MAXN];
 6 struct node
 7 {
 8     int w,h;
 9 }st[MAXN];
10 int main()
11 {
12     node temp;
13     int n,m,i,j,ans,top,wide;
14     while(~scanf("%d%d",&n,&m))
15     {
16         for(i=0;i<n;i++)
17         {
18             for(j=0;j<m;j++)
19                 scanf("%d",&a[i][j]);
20         }
21         for(i=1;i<n;i++)
22         {
23             for(j=0;j<m;j++)
24             {
25                 if(a[i][j])
26                     a[i][j]+=a[i-1][j];
27             }
28         }
29         for(ans=i=0;i<n;i++)
30         {
31             top=-1;
32             for(j=0;j<m;j++)
33             {
34                 for(wide=0;top>-1&&st[top].h>=a[i][j];top--)
35                 {
36                     wide+=st[top].w;
37                     ans=max(ans,wide*st[top].h);
38                 }
39                 temp.w=wide+1;
40                 temp.h=a[i][j];
41                 st[++top]=temp;
42             }
43             for(wide=0;top>-1;top--)
44             {
45                 wide+=st[top].w;
46                 ans=max(ans,st[top].h*wide);
47             }
48         }
49         printf("%d\n",ans);
50     }
51     return 0;
52 }
posted on 2012-07-19 20:52  DrunBee  阅读(219)  评论(0编辑  收藏  举报