please help me to figure out what is wrong with my solution https://www.codechef.com/viewsolution/10824494

1 Like

This happened with me as well.

It is happening because of n=1.

Just a separate if statement for n=1 needs to be added.

2 Likes

Please tell me what’s wrong with this : https://www.codechef.com/viewsolution/10763381

Thanks in advance.

1 Like

The order of those if statements in your code is wrong, b[j-1] has to be given preference because it can’t be added to a[j+1].

Therefore if statements having b[j-1] should be placed above others, and a few permutations can be tried

I just changed the order of if statements, in your code and got AC.

1 Like

can you again explain why the ordering is important here… i am not getting the logic behind this

Welcome