Can anyone please help me with these ZCO problems concerning Dynamic Programming.
The first Problem I want to speak of is ROUNDTABLE(The Problem):
This problem is seems analogous to Choosing Chocolates(Statement) for which I used the following code:
sol[i]= max(sol[i-1],sol[i-2]+cost[i]), for all i such that 2<=i<=n
base case:
sol[0]=0;
sol[1]=cost[1];
Now if I change the max()
to min()
it is not helping. Please Help.
The second problem is SUPW(Statement):
The problem is similar to IPL(Statement) for which I used the sub-problem formula:
Best[j,0] means he does not play match j
Best[j,1] means he plays match j, not j+1
Best[j,2] means he plays match j, j+1, not j+2
Best[j,0] = max(Best[j+1,0],Best[j+1,1],Best[j+1,2])
Consider Best[j,1] --- he plays match j and the consecutive sequence
of mathces starting at j is of length 1, so he does not play j+1. But
he does get this match fee. So:
Best[j,1] = Fee[j] + Best[j+1,0]
Best[j,2] = Fee[j] + Best[j+1,1]
Base Cases:
Best[N,0] = 0
Best[N,1] = Fee[N]
Best[N,2] = 0
Now too, if I change the max()
to min()
it is not helping. Please Help.
The contest is on 05.12.2014 I am in need of desperate help.Any ideas are welcome.