https://www.hackerrank.com/challenges/acm-icpc-team/problem
int main(){
int n, m;
scanf("%d %d",&n,&m);
char t[n][m];
for(int i = 0; i < n; i++)
scanf("%s",t[i]);
int k1, max = 0, ans = 0;
for(int i = 0; i < n-1; i++)
{
for(int j = i+1; j < n; j++)
{
k1 = 0;
for(int k = 0; k < m; k++)
if(t[i][k] == '1' || t[j][k] == '1')
k1++;
if(max < k1)
{
max = k1;
ans = 1;
}
else if(max == k1)
ans++;
}
}
printf("%d\n%d\n", max, ans);
return 0;
}
No comments:
Post a Comment