ZCO IPL Logic

I am not too good in DP and recursions. But I have tried to make this code. Some of the example inputs are running correctly but most are wrong. I am not able to figure out what’s wrong with the logic.

Code: http://pastebin.com/wLG4hst8

Question: https://www.codechef.com/ZCOPRAC/problems/ZCO14004

Hi aayushpy;

It is difficult to read code that is not commented, or otherwise explained.

Here is some code that works, by the way.

Hi agnishom;

Your code will give wrong answer for the following test case:

10

3 2 1 1 2 3 1 3 2 1

your answer : 14

expected : 15

You haven’t considered a possibility fee[i]+fee[i-1]+best[i-4] for i>=4

2 Likes
//