9697724 | CodeChef (having problem in the truth and dare beginner question)

problem : https://www.codechef.com/problems/TRUEDARE
my solution to the problem: https://www.codechef.com/viewsolution/33532610

the logic i used:-
if(ts>tr) or if(ds>dr)
i put the value of flag to 0 which indicates that shyam will win( since he can ask some things that ram cannot do) (flag being 1 indicates that ram will win)
if that if case fails, i used linearsearch function to search every true value that shyam can ask is present in the tr array or not ( the array containing the tasks ram can do)
same logic with dare array.

the OUTPUT seems to be correct when i run it on ide of codechef but it still says WA ???
thank you for your help guys

Your solution is not correct as any array may contain duplicates.

Suppose t1 = {1, 2}, t2 = {1, 2, 2}, d1 = {1}, d2 = {1, 1, 1};

In this case, your code will output “no” but the answer is “yes”.

I have commented incorrect code in this submission.

And you can use sets instead of linearsearch…

thank you so much! this was really helpful :slight_smile: