-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path29.cpp
More file actions
65 lines (56 loc) · 875 Bytes
/
29.cpp
File metadata and controls
65 lines (56 loc) · 875 Bytes
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
#include<iostream>
#include<string>
using namespace std;
int main()
{
int r, c;
int **matrix;
int *size;
int *start;
cin >> r;
cin >> c;
matrix = new int*[r];
for(int i=0; i<r; i++)
matrix[i] =new int[c];
size = new int[c];
start = new int[c];
for(int i = 0; i<c; i++)
{
size[i] = 0;
start[i] = -1;
}
for(int i=0; i<r; i++)
for(int j=0; j<c; j++)
cin >> matrix[i][j];
for(int j=0; j<c; j++)
{
for(int i=0; i<r; i++)
{
if(matrix[i][j] == 0)
{
if(start[j] = -1)
start[j] = i;
size[j]++;
}
}
}
int tsize = size[0];
int tstart = start[0];
int max = size[0];
int tmax = 0;
for(int j=1; j<c; j++)
{
if(tsize == size[j] && tstart == start[j])
tmax += size[j];
else
{
tsize = size[j];
tstart = start[j];
tmax = size[j];
}
if(tmax > max)
max = tmax;
}
cout << max << endl;
return 0;
}