PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: CodeChef Admin
Preparer: Souradeep Paul
Testers: Takuki Kurokawa, Utkarsh Gupta
Editorialist: Nishank Suresh
DIFFICULTY:
976
PREREQUISITES:
None
PROBLEM:
Given the results (pass/fail) and sizes of N test cases that a submission is run on. Find the smallest test case that fails this submission.
EXPLANATION
It is enough to implement what the statement asks for, using a loop.
Keep a variable mn, which will hold our answer. Initialize it to some large value (anything \geq 100).
Now, run a loop of i from 1 to N, and if V_i = 0, set mn \gets \min(mn, S_i). Finally, print the value of mn.
TIME COMPLEXITY:
\mathcal{O}(N) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
n = int(input())
v = list(map(int, input().split()))
s = input()
ans = 101
for i in range(n):
if s[i] == '0':
ans = min(ans, v[i])
print(ans)