Question Link : http://www.spoj.com/problems/MIXTURES/

My Solution Link :http://ideone.com/h6jHlv

Didn’t understand why the logic is wrong.

cost[i][j] = min( cost[i][j-1] + colorsum(i,j-1)*cost[j][j] , cost[i+1][j] + colorsum(i+1,j)*cost[i][i] )

=======