Team Formation solution codechef
A programming competition will be held in Chef’s city which only accepts teams of size. At least one person in a team should know a programming language and at least one person should know about the English language. It is possible that one person in a team knows both programming and the English language. Then the qualification of the other teammate is not important i.e. he may or may not know programming and English. Now Chef has students and wants to send maximum number of teams to the competition.
You are given an integer
'1' denotes that the student knows a programming language, and
'0' denotes otherwise; similarly,
'1' denotes that the student knows English language, and
'0' denotes otherwise. Determine the maximum number of teams Chef can form.
Input Format Team Formation solution codechef
- The first line of input contains a single integer denoting the number of test cases. The description of test cases follows.
- Each test case contains lines of input.
- The first line of each test case contains an integer .
- The second line of each test case contains a string .
- The last line of each test case contains a string .
For each test case, print a single line containing one integer – the maximum number of teams that Chef can form.
and contains only characters
Sample Input 1 Team Formation solution codechef
4 3 101 001 4 1010 0110 3 000 110 2 10 11
Sample Output 1
1 2 0 1
Test case: The third student can team up with any other students as he knows both programming and English.
Test case: The first two students make a team and the last two students make another team.
Test case: No student knows how to program, hence there is no way to make a team.