Spoj ACODE !! WA

Problem link - ACODE

Although I am gettting all the correct answers on all the test cases in the above problem …But on submitting getting a WA …PLease help


So the problem with your code is
there is actually no problem :stuck_out_tongue:
you just missed one case that is
when no combination exist you should print 0
but your program is printing 1. so just add the check
and your program will be accepted :slight_smile:

1 Like

@ravidelcj-Can you specify the test case in which no combination exist? Thanks.

You mean the case 0 ??


just add
if(a==0) // for no solution existing
then break from loop and print 0
otherwise continue with the procedure you are following and print dp[l-1]

Test case for no solution is

for both

you also did the same mistake
add a filter for the case when there is no combination possible

@ravidelcj-Still WA

your program is giving 0 for 1020 answer should be 1

1 Like