### ash_vs_ash's blog

By ash_vs_ash, history, 5 weeks ago, ,

I was trying to solve this problem on Codechef, " https://www.codechef.com/ICOP1904/problems/GRP ". I understand that I have to use DP to solve it and also that I have to maintain two states, but I am unable to figure out how to proceed to solve it. I even looked at some submissions but I am still not sure if I got it completely. Can someone please explain me how to solve the problem. Thanks in advance..

•
• -18
•

 » 5 weeks ago, # |   0 I was trying out this problem and i am getting WA.I have thought about the dp states and tried some test cases too and i cant find my mistake.If anyone could point out some mistake in my code it would be of great help!! Link to my solution https://ideone.com/lcUUTo .Kindly open the code in your local text editor so that the comments would be readable.Thanks in advance!!
•  » » 5 weeks ago, # ^ |   0 Try this input for which output should be -1 1 5 2 2 0 1 0 1 0 10 5 11 4 1 
•  » » » 5 weeks ago, # ^ |   0 thanks!! i thought -1 condition would never occur so i just printed ans value
 » 5 weeks ago, # |   0
•  » » 5 weeks ago, # ^ |   0 Thank you. I got it now.