Team Formation solution codechef- A programming competition will be held in Chef’s city which only accepts teams of size 22. 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 NN students and wants to send maximum number of teams to the competition.

Team Formation solution codechef

A programming competition will be held in Chef’s city which only accepts teams of size 22. 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 NN students and wants to send maximum number of teams to the competition.

You are given an integer NN and two binary strings SS and TT of length NNSi=Si= '1' denotes that the ithith student knows a programming language, and Si=Si= '0' denotes otherwise; similarly, Ti=Ti= '1' denotes that the ithith student knows English language, and Ti=Ti= '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 QQ denoting the number of test cases. The description of QQ test cases follows.
  • Each test case contains 33 lines of input.
  • The first line of each test case contains an integer NN.
  • The second line of each test case contains a string SS.
  • The last line of each test case contains a string TT.

Output Format

For each test case, print a single line containing one integer – the maximum number of teams that Chef can form.

Constraints

  • 1Q10001≤Q≤1000
  • 1N1001≤N≤100
  • SS and TT contains only characters '0' and '1'

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

Explanation

Test case 11: The third student can team up with any other students as he knows both programming and English.

Test case 22: The first two students make a team and the last two students make another team.

Test case 33: No student knows how to program, hence there is no way to make a team.

Leave a Comment