C |
Optimal Segments Input: Standard Input Output: Standard Output |
Consider a grid of size 1 x N. Each cell of the grid has the following properties
· Cell C of the grid has a value of VC(1 ≤ C ≤ N)
· The value of each cell is a positive integer less than26
· Some of the cells arespecial and they are represented with the character X
· Cell C has a weight of (two to the power of cell value)
· The special cells have weights of1
You will be given the values of these N cells and your job will be to divide these intoK segments so that
· Each segment contains at least one cell
· There is at least onespecial cell in each segment
The weight of a segment is equal to the product of the weights of the cells it contains. You have to fo