-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva10074.cpp
69 lines (59 loc) · 1.29 KB
/
uva10074.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using namespace std;
#include<iostream>
#include<cstdio>
#include<cstring>
#define max(a,b) ((a>b)?(a):(b))
int main()
{
int m,n,i,j,x,arr[110][110],k,maX,ans,temp,sum;
while(scanf("%d%d",&m,&n))
{
if(m==0&&n==0)
break;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>x;
x=x?0:1;
arr[i][j]=x;
}
}
for(i=1;i<m;i++)
{
for(j=0;j<n;j++)
{
if(arr[i][j]==1)
arr[i][j]=arr[i][j]+arr[i-1][j];
}
}
ans=0;
for(i=0;i<m;i++)
{
maX=0;
for(k=0;k<n;k++)
{
temp=arr[i][k];
sum=0;
for(j=k;j<n;j++)
{
if(temp>arr[i][j])
break;
else
sum+=temp;
}
for(x=k-1;x>=0;x--)
{
if(temp>arr[i][x])
break;
else
sum+=temp;
}
maX=max(maX,sum);
}
ans=max(maX,ans);
}
cout<<ans<<endl;
}
return 0;
}