**Physical Address**

304 North Cardinal St.

Dorchester Center, MA 02124

*Chef has recently introduced a feature, called WA Test Cases, which allows you to see the smallest test case that your WA code has failed in. For example, you can go to any relevant problem in Practice, make a submission which gets a WA verdict, and then click on the “Debug My Code” button to see the test case.*

Your job now is to find that smallest test case that a particular submission fails on. That problem has N*N* test cases, and you are given the size of each of those test cases as S_1, S_2, \ldots, S_N*S*1,*S*2,…,*S**N*. You are also given a binary string V*V*, which tells whether the submission has passed a particular test case or not. That is, if the i^{th}*i**t**h* bit of V*V* is 11, that means that the submission has passed the i^{th}*i**t**h* test case. If it is 00, then it has failed that test case. Your job is the output the size of the smallest test case where the submission has failed.

- The first line of input will contain a single integer T
*T*, denoting the number of test cases. - Each test case consists of multiple lines of input.
- The first line of each test case contains a single integer, N
*N*. - The second line contains N
*N*integers – S_1, S_2, \ldots, S_N*S*1,*S*2,…,*S**N* - The third line contains a binary string – V
*V*.

- The first line of each test case contains a single integer, N

For each test case, output on a new line, a single integer, which should be the size of the smallest test case where the submission has failed.

- 1 \leq T \leq 1001≤
*T*≤100 - 1 \leq N \leq 1001≤
*N*≤100 - 1 \leq S_i \leq 1001≤
*S**i*≤100 - Length of V = N
*V*=*N* - Each element of V
*V*is either 00 or 11 - At least one element of V
*V*will be 00

```
Input: 5
3
5 10 3
000
3
5 10 3
001
3
5 5 3
001
3
5 5 3
101
5
10 100 100 10 10
00001
Output: 3
5
5
5
10
```

**Test case 1:** There are 33 test cases, and the submission has failed all the 33 test cases. The sizes of the test cases on which it has failed are \{5, 10, 3\}{5,10,3}. The smallest among these is 33, and so the answer is 33.

**Test case 2:** There are 33 test cases, and the submission has failed on 22 test cases. The sizes of the test cases on which it has failed are \{5, 10\}{5,10}. The smallest among these is 55, and so the answer is 55.

**Test case 3:** There are 33 test cases, and the submission has failed on 22 test cases. The sizes of the test cases on which it has failed are \{5, 5\}{5,5}. The smallest among these is 55, and so the answer is 55.

**Test case 4:** There are 33 test cases, and the submission has failed on 11 test case. The sizes of the test case on which it has failed is \{5\}{5}. The smallest among these is 55, and so the answer is 55.

**Test case 5:** There are 55 test cases, and the submission has failed on 44 test cases. The sizes of the test cases on which it has failed are \{10, 100, 100, 10\}{10,100,100,10}. The smallest among these is 1010, and so the answer is 1010.

```
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
int t;
Scanner sc=new Scanner(System.in);
t=sc.nextInt();
for(int i=0;i<t;i++){
int n=sc.nextInt();
int[] a=new int[n];
for(int j=0; j<n; j++){
a[j]=sc.nextInt();
}
int min=100;
String v=sc.next();
for(int j=0; j<n; j++){
if(v.charAt(j)=='0'){
int x=j;
min=Math.min(min,a[x]);
}
}
System.out.println(min);
}
}
}
```

```
// #include <bits/stdc++.h>
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <stack>
#include <deque>
#include <queue>
#include <string>
#define ll long long int
#define arw ->
#define pb push_back
#define loop(i, a, n) for (ll i = a; i < n; i++)
#define vi vector<int>
using namespace std;
int main()
{
ll t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vi a;
loop(i, 0, n)
{
int x;
cin >> x;
a.pb(x);
}
string s;
cin >> s;
int mn = INT_MAX;
loop(i, 0, n)
{
if (s[i] == '0')
{
if (mn > a[i])
{
mn = a[i];
}
}
}
cout << mn << endl;
}
return 0;
}
```

```
t=int(input())
for i in range(t):
N=int(input())
s=list(map(int,input().split()))
v=input()
b=[]
for j in range(N):
if v[j]=='0':
b.append(s[j])
w=min(b)
print(w)
```

In our experience, we suggest you solve this WA Test Cases CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the WA Test Cases CodeChef Solution

I hope this WA Test Cases CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

**More Coding Solutions >>**