What is the difference between I and II

I used DP solution of optimal Game Strategy but it failed 5 test cases why ??

Can you also post the optimal game strategy - I as well? That way it would be better to solve the doubt while comparing differences between the two

No worries , i figured their is a difference of constraints but why this one is failing test cases , what’s wrong in this ?? I thought it would give TLE at worst but it is giving WA

Yes it happens
The test constraints in the previous questions may not hold in this one, leading to wrong segregation of answer categories leading to WA.
Ex:- suppose one question stated that a machine can only input values less than 100, so for less than 100 it will give right answer and above that TLE.
Now suppose that the threshold has been updated to 500, then if we apply the same logic then for values 101-500 it will give wrong answer

Okay , so the above solution is my answer for this problem so why i am getting WA for this question ?

Is this the answer for optimal 1 or 2? Also post the question for optimal 1 as that was what I originally asked

It is code as well as question for optimal 1

Actually both the codes are excatly same , i just wanted to know why i got WA in optimal 2

@aryan_007 main difference between both the question is that since Optimal-1 has array size of max 30 so in that question simple recursion without dp will give you All Test Case passed.
but since Optimal 2 has bigger array size using recursion without memoization will not be efficient so you need to use dp in second one while you don’t need dp in first one.
and if you are submitting same code from the first one atleast change the array size as per constraints of current problem.using dp array of size 50 will give you wrong answer for sure in second optimal problem.

1 Like

ohhhhhhh yes yes yes sir !!

but how to make an array of 10000*10000

although i made a vector of vector and it passed all the test cases but it should not have happened right ??

yeah i too was thinking that making this much size of 2d array will cause error then from looking at the editorial and test cases i found out that in any of the test cases n never goes more than 2000.that is why taking dynamic array size as per value of n is passing all test cases.

okay sir , thankyou sir !!