GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday 17 August 2022

[Solution] WA Test Cases CodeChef Solution



Problem

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 test cases, and you are given the size of each of those test cases as S_1, S_2, \ldots, S_N. You are also given a binary string V, which tells whether the submission has passed a particular test case or not. That is, if the i^{th} bit of V is 1, that means that the submission has passed the i^{th} test case. If it is 0, then it has failed that test case. Your job is the output the size of the smallest test case where the submission has failed.

Input Format

  • The first line of input will contain a single integer 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.
    • The second line contains N integers - S_1, S_2, \ldots, S_N
    • The third line contains a binary string - V.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Output Format

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.

Explanation:

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

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

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

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

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

No comments:

Post a Comment