# Hackerrank ACM ICPC Team Solution

Problem Statement
You are given a list of N people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. Find out the maximum number of topics a 2-person team can know. And also find out how many teams can know that maximum number of topics.
Input Format
The first line contains two integers N and M separated by a single space, where N represents the number of people, and M represents the number of topics. N lines follow.
Each line contains a binary string of length M. If the ith line's jth character is 1, then the ithperson knows the jth topic and doesn't know the topic otherwise.
Output Format
On the first line, print the maximum number of topics a 2-person team can know.
On the second line, print the number of 2-person teams that can know the maximum number of topics.
Constraints
2 ≤ N ≤ 500
1 ≤ M ≤ 500
Sample Input
``````4 5
10101
11100
11010
00101
``````
Sample Output
``````5
2
``````
Explanation
(1, 3) and (3, 4) know all the 5 topics. So the maximal topics a 2-person team knows is 5, and only 2 teams can achieve this.
Source Code:
`````` #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int arr,n,m,i,j,k,problem=0,team=0;
char val;
cin>>n>>m;
for(i=0;i<n;i++){
cin>>val[i];
}
int tproblem = 0,tteam = 0,flag =0;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++)
{
flag = 0;
tproblem = 0;
for(k=0;k<m;k++){
int x,y;
x = val[i][k]-48;
y = val[j][k]-48;
//cout<<x<<"x";
if(x|y){
tproblem ++;
}
}
if(tproblem == problem){
tteam++;
}
if(tproblem > problem){
problem = tproblem;
tteam= 1;
}
}
}
cout<<problem<<endl<<tteam<<endl;
return 0;
}
``````

** The above solution is my own code and it may not be the optimal solution or optimal way to approach the problem but it passes all the testcases in Hackerrank. So if you have any optimal approaches feel free to paste the code as the comment below..... :) :) :)

1. 2. 