please help me to figure out what is wrong with my solution https://www.codechef.com/viewsolution/10824494
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.
Please tell me what’s wrong with this : https://www.codechef.com/viewsolution/10763381
Thanks in advance.
Try this testcase
1 4 5 3 3 4 10 2 6 7
your code outputs -1, but the answer is 10.
Please tell me what’s wrong with this https://www.codechef.com/viewsolution/10824928
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.
Can you please tell the problem in this solution?
can you again explain why the ordering is important here… i am not getting the logic behind this
thank you @prakhariitd